Skip to content
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

Federation 2: Generated Schema does not contain directives #2606

Closed
2 of 4 tasks
sshevlyagin opened this issue Jan 18, 2023 · 4 comments
Closed
2 of 4 tasks

Federation 2: Generated Schema does not contain directives #2606

sshevlyagin opened this issue Jan 18, 2023 · 4 comments

Comments

@sshevlyagin
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Generated federation 2 schema does not contain federation 2 directives (@link, @key, etc.)

Minimum reproduction code

https://github.com/sshevlyagin/graphql/tree/ss-federation2-schema

Steps to reproduce

Run tests:e2e:fed2 under packages/apollo/package.json in this branch https://github.com/sshevlyagin/graphql/tree/ss-federation2-schema

After tests run examine content of packages/apollo/schema-generated.graphql.

Expected behavior

Expected:

  • Generated schema contains federation 2 directives (@link, @key, etc.) so that it can be used with apollo rover's dev or subgraph commands that expects a graphql file

Actual:

  • It doesn't

Package version

10.1.7

Graphql version

graphql:16.6
apollo-server-express: 3.5.0
apollo-server-fastify: 3.5.0

NestJS version

9.0.0

Node.js version

14

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@harm-less
Copy link
Contributor

Could this be connected with this issue #2559?

@sshevlyagin
Copy link
Author

Unlikely. I think the problem is the difference between the schema that gets returned on introspection to the gateway which is correct and has the directives and the schema that gets printed out which doesn’t.

I’m probably looking for flag that allows to add the Federation directives to the generated schema file or optionally generate two files one with and one without.

@cherSan
Copy link

cherSan commented Jan 25, 2023

Similar issue:

  • ApolloFederationDriver > autoSchemaFile:true does describe entities with directives in gql file but generate descriptions of directives (example directive @OverRide(from: String!) on FIELD_DEFINITION)
  • Similar with MercuriusFederationDriver > autoSchemaFile:true
  • autoSchemaFile: { federation: 2 } does not generate descriptions of directives in the gql file and does not describe entities with directives

node -v v18.12.1

devDependencies

"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@nrwl/cli": "15.6.2",
"@nrwl/eslint-plugin-nx": "15.6.2",
"@nrwl/jest": "15.6.2",
"@nrwl/linter": "15.6.2",
"@nrwl/nest": "15.6.2",
"@nrwl/node": "15.6.2",
"@nrwl/nx-cloud": "15.0.2",
"@nrwl/webpack": "15.6.2",
"@nrwl/workspace": "15.6.2",
"@types/jest": "28.1.1",
"@types/node": "18.7.1",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"eslint": "~8.15.0",
"eslint-config-prettier": "8.1.0",
"jest": "28.1.1",
"jest-environment-jsdom": "28.1.1",
"nx": "15.6.2",
"prettier": "^2.6.2",
"ts-jest": "28.0.5",
"ts-node": "10.9.1",
"typescript": "~4.8.2"

dependencies

"@apollo/federation": "^0.38.1",
"@apollo/subgraph": "^2.2.3",
"@nestjs/apollo": "^10.1.7",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/graphql": "^10.1.7",
"@nestjs/platform-express": "^9.0.0",
"apollo-server-core": "^3.11.1",
"apollo-server-express": "^3.11.1",
"axios": "^1.0.0",
"graphql": "^16.6.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.0.0",
"tslib": "^2.3.0"

Module Import

GraphQLModule.forRoot<ApolloFederationDriverConfig>({ driver: ApolloFederationDriver, autoSchemaFile: { path: `${process.cwd()}/apps/server/schema.gql` } })

Model contain

@directive('@key(fields: "id")')
@ObjectType()
export class User {
@field(() => ID)
id: string;
}

GQL Generated

...
directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

directive @OverRide(from: String!) on FIELD_DEFINITION

type User {
id: ID!
}

@kamilmysliwiec
Copy link
Member

Please search through some of our old issues on this (this has been discussed several times in the past).

@nestjs nestjs locked and limited conversation to collaborators Jan 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants