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

Subgraph doesn't work #2375

Open
Brilhante29 opened this issue Feb 6, 2023 · 7 comments
Open

Subgraph doesn't work #2375

Brilhante29 opened this issue Feb 6, 2023 · 7 comments

Comments

@Brilhante29
Copy link

When I run my project with subgraphs in the latest version of node and nestjs, I got this error

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

@TLadd
Copy link

TLadd commented Feb 6, 2023

I experienced the same error going from 2.2.3 -> 2.3.0 using pothos as my schema builder.

@saevarb
Copy link

saevarb commented Feb 6, 2023

I also just ran into this same issue when going from 2.0.5 to 2.3.0. In particular, this happens when calling builder.toSubgraphSchema. The primary motivation for this upgrade was getting support for node 18, but it seems e.g. 2.2.3 is fine for my use case for now.

@Brilhante29
Copy link
Author

with 2.2.3 works perfectly?

@alexbchr
Copy link

alexbchr commented Feb 8, 2023

Same problem here with 2.3.0 and 2.3.1. No issue with 2.2.3

@sachindshinde
Copy link
Contributor

From what we can tell, this error occurs for subgraphs when they're using the @tag directive definition from federation spec version 2.3, i.e.

directive @tag(name: String!) repeatable on
  | FIELD_DEFINITION
  | INTERFACE
  | OBJECT
  | UNION
  | ARGUMENT_DEFINITION
  | SCALAR
  | ENUM
  | ENUM_VALUE
  | INPUT_OBJECT
  | INPUT_FIELD_DEFINITION 
  | SCHEMA

but if their subgraph schema is declaring a lower federation spec, e.g.

extend schema @link(url: "https://specs.apollo.dev/federation/v2.2", ...)

You'll need to either upgrade your subgraph to use federation spec v2.3 e.g. with

extend schema @link(url: "https://specs.apollo.dev/federation/v2.3", ...)

or you'll need to use the @tag directive definition of your declared federation spec version (or alternatively omit the @tag directive definition if possible, as buildSubgraphSchema() should automatically add the appropriate definition).

sachindshinde added a commit that referenced this issue Feb 8, 2023
We've seen folks accidentally forgetting to bump their federation spec to `v2.3` when using the latest `@tag` directive definition that includes `SCHEMA`, which will result in an error from `buildSubgraphSchema()` (see #2375 ). This PR updates the `CHANGELOG.md` to explicitly state this.
@zhumeisongsong
Copy link

With 2.2.3 works perfectly.

@marc-wilson
Copy link

Still in issue in 2.9.3. After downgrading to 2.2.3 it worked.

Any update on when we can expect a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants