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

Cannot start Federated Service: Invalid definition for directive "@tag" #2477

Closed
nmacherey opened this issue Mar 17, 2023 · 4 comments
Closed
Labels
P2 An issue that needs to be addressed on a reasonable timescale.
Milestone

Comments

@nmacherey
Copy link

Issue Description

/Users/nmacherey/WORK/io.getbigger.api/node_modules/@apollo/federation-internals/src/error.ts:66
super(
^
GraphQLError: The schema is not a valid GraphQL schema.. Caused by:
Invalid definition for directive "@tag": "@tag" should have locations FIELD_DEFINITION, OBJECT, INTERFACE, UNION, ARGUMENT_DEFINITION, SCALAR, ENUM, ENUM_VALUE, INPUT_OBJECT, INPUT_FIELD_DEFINITION, but found (non-subset) FIELD_DEFINITION, OBJECT, INTERFACE, UNION, ARGUMENT_DEFINITION, SCALAR, ENUM, ENUM_VALUE, INPUT_OBJECT, INPUT_FIELD_DEFINITION, SCHEMA
at new AggregateGraphQLError (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@apollo/federation-internals/src/error.ts:66:5)
at aggregateError (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@apollo/federation-internals/src/error.ts:87:10)
at ErrGraphQLValidationFailed (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@apollo/federation-internals/src/definitions.ts:52:17)
at buildSchemaFromAST (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@apollo/federation-internals/src/buildSchema.ts:173:37)
at buildSubgraph (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@apollo/federation-internals/src/federation.ts:1249:27)
at buildSubgraphSchema (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@apollo/subgraph/src/buildSubgraphSchema.ts:60:33)
at GraphQLFederationFactory.generateSchemaFromCodeFirst (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@nestjs/graphql/dist/federation/graphql-federation.factory.js:69:32)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at GraphQLFederationFactory.generateSchema (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@nestjs/graphql/dist/federation/graphql-federation.factory.js:31:22)
at GraphQLModule.onModuleInit (/Users/nmacherey/WORK/io.getbigger.api/node_modules/@nestjs/graphql/dist/graphql.module.js:103:27)

Link to Reproduction

none

Reproduction Steps

Version used

"@apollo/client": "^3.7.10",
"@apollo/federation-internals": "^2.3.5",
"@apollo/gateway": "^2.3.5",
"@apollo/server": "^4.5.0",
"@apollo/subgraph": "^2.3.5",

I've tried with different version, 2.2.1 to 2.3.5.
Thanks for your help

@pcmanus
Copy link
Contributor

pcmanus commented Mar 17, 2023

This error happens if the schema has a definition for the @tag directive that differs from what is expected by the federation specification linked in the schema. See this comment too.

It's difficult to help more without some additional details, but essentially the schema provided to the buildSubgraphSchema method has some definition for directive @tag and that definition should probably be removed (since buildSubgraphSchema will add it back with the exact definition it expects).

@zhumeisongsong
Copy link

With 2.2.3 works perfectly.

@korinne korinne added the P2 An issue that needs to be addressed on a reasonable timescale. label Mar 24, 2023
@korinne korinne added this to the 2.5 milestone Mar 24, 2023
@trevor-scheer
Copy link
Member

This appears to be a package version issue. @nmacherey are you still experiencing this / did you find a resolution? If not, can you share the output of:
npm ls @apollo/subgraph

Also I can't think of a reason why you should have @apollo/federation-internals specified as a dependency in your project. Are you using it for something?

Related issue in nestjs, where the solution seems to be "just upgrade":
nestjs/graphql#2646 (comment)

@trevor-scheer
Copy link
Member

Closing as stale (and possibly solved). Happy to reopen if the issue persists and we get a reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 An issue that needs to be addressed on a reasonable timescale.
Projects
None yet
Development

No branches or pull requests

5 participants