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

Directives on root fields are lost in subschema requests #6292

Open
3 of 4 tasks
kemper0110 opened this issue Jun 27, 2024 · 0 comments
Open
3 of 4 tasks

Directives on root fields are lost in subschema requests #6292

kemper0110 opened this issue Jun 27, 2024 · 0 comments

Comments

@kemper0110
Copy link

kemper0110 commented Jun 27, 2024

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
    > Make sure to fork this template and run yarn generate in the terminal.
    >
    > Please make sure the GraphQL Tools package versions under package.json matches yours.
  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

When I use directive on the root field, the @graphql-tools/delegate loses directive on subschema request.

To Reproduce Steps to reproduce the behavior:

  1. Make schema with custom directive on FIELD and query with root field.
      directive @strExpr on FIELD
      type Query {
          hello: String
      }
  1. Stitch single schema with mergeDirectives (maybe can be replaced with delegateToSchema but idk how).
  2. Pass graphql request to stitched schema with directive on root field.
      query getHello {
          hello @strExpr
      }
  1. The request passed to resolver has no directive on the root field.
query getHello {
  __typename    
  hello
}

Try online
https://codesandbox.io/p/devbox/stitching-directives-vvp6xj

Expected behavior

There is a directive on the request, as well as on the original request.

query getHello {
  __typename    
  hello @strExpr
}

Environment:

  • OS: windows 10
  • @graphql-tools/delegate: 10.0.11
  • NodeJS: v18.18.2

My solution

Add to object rootfieldNode in @graphql-tools/delegate/cjs/createRequest.js directives: fieldNodes?.[0]?.directives to pass directives to new request.

Additional context

I am not sure enough, but maybe mergedOperationDefinition also requires directives support for operations?

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