Federated schema SDL cannot include federation definitions
See original GitHub issueLibrary Version apollo-server: 2.9.3
Describe the bug
Federated GraphQL schema requires specific SDL to be returned from the GraphQL _service
query (i.e. it should include all the types available in the schema that are conditionally annotated with federation directives). GraphQL servers utilizing graphql-java
have a severe limitation in how they generate the SDL from the schema - we cannot conditionally include/exclude certain directives when generating the SDL. If we specify that we want to include directives in the SDL it will print out all directives present in the schema. Correct SDL could be generated by manipulating the generated default SDL String but that solution does not seem very robust. Instead, it would be great if apollo-server
could accept complete SDL when processing federated schemas.
To Reproduce Run federated example from examples/federation that includes two Spring Boot apps and Apollo Gateway.
Gateway will fail to start with following error
(node:16995) UnhandledPromiseRejectionWarning: GraphQLSchemaValidationError: Unknown directive "lowercase".
Unknown directive "lowercase".
at ApolloGateway.createSchema (/Users/DKuc/Development/graphql-kotlin/examples/federation/gateway/node_modules/@apollo/gateway/dist/index.js:174:19)
at ApolloGateway.<anonymous> (/Users/DKuc/Development/graphql-kotlin/examples/federation/gateway/node_modules/@apollo/gateway/dist/index.js:151:32)
at Generator.next (<anonymous>)
at fulfilled (/Users/DKuc/Development/graphql-kotlin/examples/federation/gateway/node_modules/@apollo/gateway/dist/index.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
(node:16995) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Expected behavior Federated gateway starts successfully and exposes complete federated schema.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:5 (4 by maintainers)
Top GitHub Comments
They added support only for executable directives. Spec: http://spec.graphql.org/June2018/#ExecutableDirectiveLocation
Reopening this issue because, as @dariuszkuc pointed out to me offline, this issue was less about custom directives and more about federation directives. The goal of this issue is to allow services to return their complete SDL rather than have to strip it of federation specific definitions (directives, etc.).