Graphql-code-generator: Apollo Federation @key directive: "Nested fields in _FieldSet is not supported"

Created on 26 Sep 2019  ·  2Comments  ·  Source: dotansimha/graphql-code-generator

Describe the bug
Attempting to use nested fields in the @key directive returns an error, even though it's a supported syntax introduced in @apollo/federation.

To Reproduce
Attempt to use nested fields in @key

Example:

type User @key(fields: "id organization { id }") {
  id: ID!
  organization: Organization!
}
✔ Parse configuration
  ❯ Generate outputs
    ❯ Generate src/generated/graphql.ts
      ✔ Load GraphQL schemas
      ✔ Load GraphQL documents
      ✖ Generate
        → Nested fields in _FieldSet is not supported

Not sure if this is technically a bug or just a missing feature, but I couldn't find anyone else having this issue elsewhere. Is it planned to be supported?

enhancement plugins

Most helpful comment

It just a missing feature and we chose to throw an exception here because the output is incorrect, so the generation failed. We will implement it soon but if someone wants to help, reach out to us :)

All 2 comments

As a workaround, is there a way to simply ignore this particular error? Would be nice to have typedefs where it's supported but ignored where it's not.

--silent silences errors, but I'd prefer it to not silence everything, and generate code for whatever works, without feeling the need to avoid using nested fields in @key just because a code generator doesn't support it.

Since the schema is completely valid, I'd argue that this shouldn't even be an error, instead a warning that happens once when you try to generate code, with the preferred ability to silence.

It just a missing feature and we chose to throw an exception here because the output is incorrect, so the generation failed. We will implement it soon but if someone wants to help, reach out to us :)

Was this page helpful?
0 / 5 - 0 ratings