-
Notifications
You must be signed in to change notification settings - Fork 398
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
Apollo federation with code-first approach adds "@tag" to schema, throwing "invalid definition for directive "@tag" #2646
Comments
Hi @sebastiangug, there is an open issue in the repository of the federation of so it is not a problem related to the however by updating these packages in your minimal reproduction
you solve the problem ( see screenshot ) i hope i have been helpful |
My solution is to use the federation version 2, and you don't have to limit the version of package GraphQLModule.forRoot<ApolloFederationDriverConfig>({
driver: ApolloFederationDriver,
// use the federation version 2
autoSchemaFile: isOnline ? false : { path: "schema.gql", federation: 2 },
}) |
@Tony133 Thank you, man! You've saved my day! P.S. For those who are exposing the schema as a subgraph |
Tl;DR:
I think this should be re-opened this error is currently demonstrable in the NestJS sample repo as it currently exists. This issue is happening in the NestJS sample federated code first example: https://github.com/nestjs/nest/tree/master/sample/31-graphql-federation-code-first Pull that sample project, install the dependencies of each subgraph with a The dependencies of that sample repo are set to:
The issue persists if you update all dependencies as well:
Also a related question: In the sample codebase, with the above dependencies if you try to use Federation 2 by changing the config to:
Then the schema generated by
But the "@tag" error will go away, but I do not think this is producing a correct subgraph schema. (Seems related to #2231 or #1597) as directives are missing. The schema still seems to be usable though through the gateway, and if you introspect through gql playground you can see the directives Introspection of user GQL endpoint running with Federation 2 config:
|
This is happening again on @apollo/subgraph version 2.7.6 |
Is there an existing issue for this?
Current behavior
With the code-first approach and with the federation driver (not the normal one), there is this bit that gets added by default to the schema:
This then makes the server throw on startup:
Minimum reproduction code
https://github.com/sebastiangug/nest-graphql-vite
Steps to reproduce
Expected behavior
Application should start
Package version
10.1.7
Graphql version
graphql
: 16.6.0apollo-server-express
: 3.11.1apollo-server-fastify
:NestJS version
9.3.2
Node.js version
19.5.0
In which operating systems have you tested?
Other
EDIT:
Changing these two dependencies to this version seems to fix the issue, therefore I'm guessing nestjs's code-first approach just doesn't support whatever was changed between those two versions?
The text was updated successfully, but these errors were encountered: