-
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
Directives missing in the autogenerated GraphQL Schema if using code-first approach (annotations inside the model are ignored) #1597
Comments
Can you make a minimum reproduction that doesn't have the database dependency? Is this only for federation or does it happen for regular GQL too? |
I created two branches:
|
#1278 (comment) |
After some investigation and reverse engineering, I think that the issue reported by @kamilmysliwiec (graphql/graphql-js#1343) has been fixed by an own implementation of Apollo. In fact by inspecting nestjs code, the schema is autogenerated by using the graphql/lib/graphql-schema.builder.ts Line 106 in 3a7468e
By logging the As stated above, Apollo has fixed the issue graphql/graphql-js#1343 in its own implementation, as also stated at the head of the code: https://github.com/apollographql/federation/blob/main/federation-js/src/service/printFederatedSchema.ts In fact, nestjs uses that at runtime and by logging the generated schema by Apollo, I can see correctly the directives: So in order to autogenerate from nestjs the correct GraphQL Schema (with the directives), in the following file I've changed the import of the By doing this, now the autogenerated GraphQL Schema file is correct (with the directives):
|
@keadex , your solution is perfect ! Thanks a lot. |
…pproach Federated schema generated with the code first approach does not contain the directives. Closes nestjs#1597
I'm submitting a...
Current behavior
I'm trying to build multiple GraphQL Microservices (Experience Service and Company Service) by using Apollo Federation and code-first approach.
I've followed this documentation: https://docs.nestjs.com/graphql/federation#federation
Basically:
https://github.com/keadex/keadex-einaudi/blob/0.0.1/apps/company/src/models/experience.model.ts
The problem is that, the autogenerated GraphQL Schema ignores all the Directives, included the @extends one:
Expected behavior
With the code-first approach I expect that NestJS, during the generation of the GraphQL Schema, takes into account all the directives added inside the model, autogenerating so a schema like the following one:
Minimal reproduction of the problem with instructions
The repo with the full code (Experience Service, Company Service, Gateway) is the following one: https://github.com/keadex/keadex-einaudi/tree/0.0.1
This is the Experience model (which extends the one inside the Experience Service - https://github.com/keadex/keadex-einaudi/blob/0.0.1/apps/experience/src/models/experience.model.ts) inside the Company Service: https://github.com/keadex/keadex-einaudi/blob/0.0.1/apps/company/src/models/experience.model.ts
What is the motivation / use case for changing the behavior?
Is not possible to extend GraphQL types and create GraphQL microservices separated by concern leveraging on Apollo Federation.
Environment
The text was updated successfully, but these errors were encountered: