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.

ApolloGateway doesn't recognize federation-jvm hosted graphql

See original GitHub issue

_query { _service { sdl } } on federation-jvm gives

{
  "errors": [],
  "data": {
    "_service": {
      "sdl": "schema {\n  query: Query\n}\n\ntype Query {\n  me: User\n}\n\ntype User @key(fields : \"id\") {\n  id: ID!\n  name: String\n  username: String\n}\n"
    }
  },
  "extensions": null,
  "dataPresent": true
}

while ApolloGateway is expecting a different format with the same schema.grapql file:

{
  "data": {
    "_service": {
      "sdl": "extend type Query {\n  me: User\n}\n\ntype User @key(fields: \"id\") {\n  id: ID!\n  name: String\n  username: String\n}\n"
    }
  }
}

https://github.com/apollographql/federation-demo/blob/master/services/accounts/index.js#L4

ApolloGateway doesn’t like the empty Array in .errors. ApolloGateway considers this as not having a schema, and it also complains when having schema {\n query: Query\n}\n\n in sdl.

Once the sdl string is patched and the empty array .errors is removed, the Graphql schema defined in federation-jvm starts to appears on ApolloGateway.

snippet to patch the sql string:

final String modified = sdl.replace("schema {\n  query: Query\n}\n\n", "");
_service.put("sdl", modified);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
yuhanzcommented, Aug 21, 2019

The first part is a non-issue in the spring-example. (.errors:[] was introduced because we serialized ExecutionResult directly.)

So, the only problem is with the schema {\n query: Query\n} in the sdl

0reactions
sachindshindecommented, May 13, 2020

@kenshih @areidt84 @omarsallah00 I believe your issues are similar to #23 , which ended up being a bug in graphql-java’s SchemaPrinter. We’ve patched their printer in federation-jvm v0.3.4 and above, let me know if you’re still experiencing issues and I can reopen this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to Apollo Federation - Apollo GraphQL Docs
With federation, you can responsibly share ownership of your supergraph across any number of teams. And even if you currently only have one...
Read more >
Building scalable solutions with Apollo Federation and Fauna
This article explains how you can reduce complexity, develop features faster, and make your engineering teams more efficient using Apollo ...
Read more >
Federation | NestJS - A progressive Node.js framework
This method is triggered by the Apollo Gateway whenever a related resource requires a User instance. We'll see an example of this in...
Read more >
Monitor Apollo Server with OpenTelemetry - New Relic
One of the benefits of using GraphQL language is that it makes it ... so if a query runs through multiple resolvers you...
Read more >
Implementing a GraphQL gateway with Fastify - NearForm
GraphQL integration with caching of both query parsing and validation. Automatic loader integration to avoid 1+N queries (see this video ...
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