Skip to content

fix(fragment-matcher): don't introspect a schema that declares @defer/@stream - #10927

Open
bengry wants to merge 1 commit into
dotansimha:masterfrom
bengry:fragment-matcher-defer-stream-introspection
Open

fix(fragment-matcher): don't introspect a schema that declares @defer/@stream#10927
bengry wants to merge 1 commit into
dotansimha:masterfrom
bengry:fragment-matcher-defer-stream-introspection

Conversation

@bengry

@bengry bengry commented Aug 24, 2026

Copy link
Copy Markdown

Fixes #10894.

graphql 17's execute() refuses to run against a schema that declares @defer or @stream, whether
or not the document uses them. The introspection query here doesn't use either, but having @defer in
the SDL is enough to kill codegen. We declare it so @graphql-eslint picks it up in operations, and
there's no config option to skip past this.

Introspect a copy without them instead:

const cleanSchema =
  federationlessSchema.getDirective('defer') || federationlessSchema.getDirective('stream')
    ? new GraphQLSchema({
        ...federationlessSchema.toConfig(),
        directives: federationlessSchema
          .getDirectives()
          .filter(d => d.name !== 'defer' && d.name !== 'stream'),
      })
    : federationlessSchema;

Only rebuilds when one of them is actually declared, so nothing changes otherwise.

Output is unaffected. The same schema on graphql 16 unpatched and on graphql 17 patched both give:

{ "possibleTypes": { "Node": ["User", "Post"], "Content": ["User", "Post"] } }

Also ran it across our own codegen configs, generated output unchanged.

The test can't fail on the graphql 16 pinned here, since 16's execute() doesn't throw. It starts
guarding properly whenever the repo moves to 17.

@changeset-bot

changeset-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 82fae91

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/fragment-matcher Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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

Successfully merging this pull request may close these issues.

fragment-matcher fails with @stream/defer directives

1 participant