question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Federated schema SDL cannot include federation definitions

See original GitHub issue

Library 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:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ilinoyercommented, Jan 15, 2020

They added support only for executable directives. Spec: http://spec.graphql.org/June2018/#ExecutableDirectiveLocation

0reactions
trevor-scheercommented, Jun 3, 2020

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.).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apollo Federation subgraph specification
If supporting Federation 1, sdl must omit all automatically added definitions from Subgraph schema additions, such as Query._service and _Service.sdl ! If your ......
Read more >
Schema Stitching & Federation: Not the Best Solutions for ...
There are different ways to bring together GraphQL microservices, like schema stitching and Federation. But these solutions aren't the most ...
Read more >
Create Apollo-Server with Federated schema - Stack Overflow
How can I load the schema from the file with the correct type to feed it as TypeDefs for the Federated Schema? import...
Read more >
Shared types in GraphQL Federation (@shareable)
Hello - I am testing out GraphQL Federation in Tyk Dashboard. ... not build federated schema” error=“parse graphql document string: ...
Read more >
Federation error codes - Apollo GraphQL Docs
When Apollo Gateway attempts to compose the schemas provided by your subgraphs ... @key includes at least one field that's also defined in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found