Skip to content

Commit

Permalink
Use fed internals schema printer
Browse files Browse the repository at this point in the history
  • Loading branch information
tninesling committed Aug 26, 2024
1 parent ac6c6d2 commit 4ff041b
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 62 deletions.
6 changes: 2 additions & 4 deletions router-bridge/js-src/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
printSchema,
graphqlSync,
} from "graphql";
import { printSchemaWithDirectives } from "@graphql-tools/utils";

import {
Operation,
operationFromDocument,
printSchema as printSchemaWithDirectives,
Supergraph,
} from "@apollo/federation-internals";
import {
Expand Down Expand Up @@ -282,9 +282,7 @@ export class BridgeQueryPlanner {
let result = new Map<string, string>();

subgraphs.names().forEach((name) => {
let sdl = printSchemaWithDirectives(
subgraphs.get(name).schema.toGraphQLJSSchema({})
);
let sdl = printSchemaWithDirectives(subgraphs.get(name).schema);
result.set(name, sdl);
});

Expand Down
26 changes: 0 additions & 26 deletions router-bridge/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion router-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@apollo/query-planner": "^2.9.0-beta.0",
"@apollo/usage-reporting-protobuf": "^4.0.0",
"@apollo/utils.usagereporting": "^3.0.0",
"@graphql-tools/utils": "9.2.1",
"graphql": "16.6.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ expression: snapshot
--------------------
subgraphWithCost
--------------------
schema @link(url: "https://specs.apollo.dev/link/v1.0") @link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"]) {
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"])
{
query: Query
}

Expand Down Expand Up @@ -58,6 +61,7 @@ enum link__Purpose {
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
Expand All @@ -74,14 +78,19 @@ scalar federation__Policy

scalar federation__ContextFieldValue

enum AorB @federation__cost(weight: 15) {
enum AorB
@federation__cost(weight: 15)
{
A
B
}

scalar ExpensiveInt @federation__cost(weight: 30)
scalar ExpensiveInt
@federation__cost(weight: 30)

type ExpensiveObject @federation__cost(weight: 40) {
type ExpensiveObject
@federation__cost(weight: 40)
{
id: ID
}

Expand All @@ -107,7 +116,10 @@ type _Service {
--------------------
subgraphWithListSize
--------------------
schema @link(url: "https://specs.apollo.dev/link/v1.0") @link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"]) {
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"])
{
query: Query
}

Expand Down Expand Up @@ -160,6 +172,7 @@ enum link__Purpose {
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
source: router-bridge/src/planner.rs
expression: schema
---
schema @link(url: "https://specs.apollo.dev/link/v1.0") @link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"]) {
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"])
{
query: Query
}

Expand Down Expand Up @@ -59,6 +62,7 @@ enum link__Purpose {
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
Expand All @@ -75,7 +79,9 @@ scalar federation__Policy

scalar federation__ContextFieldValue

type Book implements Product @key(fields: "isbn") {
type Book implements Product
@key(fields: "isbn")
{
isbn: String!
title: String
year: Int
Expand All @@ -99,7 +105,9 @@ type KeyValue {
value: String! @shareable
}

type Library @key(fields: "id") {
type Library
@key(fields: "id")
{
id: ID!
name: String
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
source: router-bridge/src/planner.rs
expression: schema
---
schema @link(url: "https://specs.apollo.dev/link/v1.0") @link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"]) {
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"])
{
query: Query
}

Expand Down Expand Up @@ -59,6 +62,7 @@ enum link__Purpose {
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
source: router-bridge/src/planner.rs
expression: schema
---
schema @link(url: "https://specs.apollo.dev/link/v1.0") @link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"]) {
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"])
{
query: Query
}

Expand Down Expand Up @@ -59,6 +62,7 @@ enum link__Purpose {
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
Expand All @@ -75,7 +79,9 @@ scalar federation__Policy

scalar federation__ContextFieldValue

type Book implements Product @key(fields: "isbn") {
type Book implements Product
@key(fields: "isbn")
{
inStock: Boolean
isCheckedOut: Boolean
isbn: String!
Expand All @@ -86,7 +92,9 @@ type Book implements Product @key(fields: "isbn") {
details: ProductDetails @external
}

type Furniture implements Product @key(fields: "sku") {
type Furniture implements Product
@key(fields: "sku")
{
inStock: Boolean
isHeavy: Boolean
sku: String!
Expand Down Expand Up @@ -119,7 +127,9 @@ type ProductDetailsFurniture implements ProductDetails {
color: String @shareable
}

type User @key(fields: "id") {
type User
@key(fields: "id")
{
goodDescription: Boolean @requires(fields: "metadata{description}")
id: ID!
metadata: [UserMetadata] @external
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
source: router-bridge/src/planner.rs
expression: schema
---
schema @link(url: "https://specs.apollo.dev/link/v1.0") @link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"]) {
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/federation/v2.9", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective", "@interfaceObject"])
{
query: Query
}

Expand Down Expand Up @@ -59,6 +62,7 @@ enum link__Purpose {
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY

"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
Expand All @@ -79,7 +83,9 @@ type Amazon {
referrer: String
}

type Book implements Product @key(fields: "isbn") {
type Book implements Product
@key(fields: "isbn")
{
upc: String!
sku: String!
name(delimeter: String = " "): String @requires(fields: "title year")
Expand All @@ -93,7 +99,9 @@ type Book implements Product @key(fields: "isbn") {

union Brand = Ikea | Amazon

type Car implements Vehicle @key(fields: "id") {
type Car implements Vehicle
@key(fields: "id")
{
id: String!
description: String
price: String
Expand All @@ -105,7 +113,10 @@ type Error {
message: String @shareable
}

type Furniture implements Product @key(fields: "upc") @key(fields: "sku") {
type Furniture implements Product
@key(fields: "upc")
@key(fields: "sku")
{
upc: String!
sku: String!
name: String
Expand Down Expand Up @@ -161,13 +172,17 @@ type Query {

union Thing = Car | Ikea

type User @key(fields: "id") {
type User
@key(fields: "id")
{
vehicle: Vehicle
thing: Thing
id: ID!
}

type Van implements Vehicle @key(fields: "id") {
type Van implements Vehicle
@key(fields: "id")
{
id: String!
description: String
price: String
Expand Down
Loading

0 comments on commit 4ff041b

Please sign in to comment.