-
-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[plugin-federation] schema should contain @key directives on entities #427
Comments
This is an issue with graphql. As you can see in the snapshots when using the printSubGraphSchema method, the directive is defined. GraphQLs printSchema method doesn't support printing directives. The solution is to use another printing method. One option is https://github.com/ardatan/graphql-tools/blob/master/packages/utils/src/print-schema-with-directives.ts There are some long discussions around this in the graphql repo, but it's currently considered working as intended, which is unfortunate, and an issue that should probably be revised now that there is more active development it. |
If you want to go down the rabbit hole: graphql/graphql-js#1343 is the current state of this issue. |
We probably should have better docs around how to set up federation and some of these limitations. I personally don't have much experience with, or use for apollo federation, other than writing this plugin. Would be happy to take any feedback or suggestions (or contributions) you might have for the API or docs. |
Hey, thank you for the response. That is quite the rabbit hole! given it's a GQL specific implementation, we were able to work around it for our use case without relying on the output of an introspection on the pothos graph sdl. Since doing that, and moving forward with our implementation, we have spotted some other issues in terms of how the Lets say we have a
The
I can't tell if I have missed something, an implementation detail, or if there is a bug going in the plugin. I would most certainly expect the |
Interesting. This is the second report I've gotten today about entities not resolving correctly. I'll take a look tonight and see if I can figure out what's going on. |
@leeroyrose Just released an update that I think might fix your issue. There were some big breaking changes in a patch release of |
That is awesome. I have tested and can confirm the entities query is now resolving and the resolveReference handler is being called. Thank you for your efforts on this! 👏🌟 |
I've been stumbling around with apollo yelling at me trying to get federation to work, and it eventually lead me to issue hayes#427. Switching to `printSubgraphSchema` fixed the problem, but I did not try your other suggested alternative.
Using the example graph created for the unit tests
When a graph is introspected that implements
builder.asEntity
, the@key
directive is missing from the output - as seen in the unit test snapshots test snapshots. The expected output would be similar to this snapshotThough the graph technically resolves it's entities correctly (due to the _service { sdl } query rendering the @key directive), it's making graph composition using the rover cli fail.
Is this something that would be acceptable to add? If so, I can work on a PR. Thank you!
The text was updated successfully, but these errors were encountered: