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

Maximum call stack error on recursive @requires directives #2830

Open
lleadbet opened this issue Oct 19, 2023 · 0 comments
Open

Maximum call stack error on recursive @requires directives #2830

lleadbet opened this issue Oct 19, 2023 · 0 comments

Comments

@lleadbet
Copy link
Contributor

Issue Description

This is low priority.

When writing a subgraph schema and you happen to requires a field that also requires that field, you end up with a composition failure due to a maximum call stack size.

Ideally this should be a composition error to provide clear reasoning as to why it was happening.

Link to Reproduction

https://codesandbox.io/p/sandbox/apollo-gateway-ckyqqj

Reproduction Steps

Given subgraph a:

extend schema
  @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@external", "@requires"])

type Query {
  f: [Foo!]!
}
type Foo @key(fields: "id") {
  id: ID!
  bar: Bar!  @requires(fields:"baz { b }")
  baz: Baz! @external
}

type Bar {
  a: String! 
}

type Baz {
  b: String! @external
}

And subgraph b:

extend schema
  @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@external", "@requires"])

type Foo @key(fields:"id"){
  id: ID!
  bar: Bar! @external
  baz: Baz! @requires(fields:"bar { a }")
}

type Bar {
  a: String! @external
}

type Baz {
  b: String!
}

And trying to compose via Rover, you'll get:

rover supergraph compose --config supergraph.yaml > schema.graphqls
⌛ resolving SDL for subgraphs defined in supergraph.yaml
🎶 composing supergraph with Federation v2.5.4
error[E029]: Encountered 1 build error while trying to build a supergraph.

Caused by:
    UNKNOWN: RangeError: Maximum call stack size exceeded
    
        The subgraph schemas you provided are incompatible with each other. See https://www.apollographql.com/docs/federation/errors/ for more information on resolving build errors.

And similar for the code example.

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

1 participant