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

Schema stitching bug when multiple versions of delegate in workspace #5130

Open
2 of 4 tasks
Tracked by #5201 ...
neumark opened this issue Mar 27, 2023 · 0 comments
Open
2 of 4 tasks
Tracked by #5201 ...

Schema stitching bug when multiple versions of delegate in workspace #5130

neumark opened this issue Mar 27, 2023 · 0 comments

Comments

@neumark
Copy link
Contributor

neumark commented Mar 27, 2023

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 multiple copies of @graphql-tools/delegate are available in a workspace (eg: because stitch and wrap depend on different versions), creating symbols with Symbol() can lead to bugs when one version of delegate sets an object property using its version of the symbol which the other delegate instance will not be able to access.

The problem occurs in executeDelegationStage, when the selectionSet fields returned by the stitched subschema are merged with the existing fields. Due to multiple versions of delegate, each with it's own instance of OBJECT_SUBSCHEMA_SYMBOL, the subschema information associated with symbols set in annotateExternalObject() by one delegate instance cannot be accessed by executeDelegationStage() within another instance.

Using Symbol.for() fixes this: as long as both versions of delegate use the same string description, they will refer to the same symbol.

To Reproduce
Steps to reproduce the behavior:

Our dependency tree:

└─ @cloud/unified@workspace:cloud/unified
   ├─ @graphql-tools/delegate@npm:8.4.2 [55f8a] (via npm:8.4.2 [55f8a])
   ├─ @graphql-tools/stitch@npm:8.4.2 [55f8a] (via npm:8.4.2 [55f8a])
   │  ├─ @graphql-tools/batch-delegate@npm:8.2.2 [bfa3d] (via npm:8.2.2 [bfa3d])
   │  │  └─ @graphql-tools/delegate@npm:8.4.2 [55f8a] (via npm:8.4.2 [55f8a])
   │  ├─ @graphql-tools/delegate@npm:8.4.2 [55f8a] (via npm:8.4.2 [55f8a])
   │  └─ @graphql-tools/wrap@npm:8.5.1 [bfa3d] (via npm:^8.3.1 [bfa3d])
   │     └─ @graphql-tools/delegate@npm:8.8.1 [ccd30] (via npm:8.8.1 [ccd30])

Expected behavior

Environment:

  • OS: linux
  • @graphql-tools/...:
  • NodeJS: 16.10.0

Additional context

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