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

Composition issue infinite recursion with @requires use #3060

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tinnou
Copy link
Contributor

@tinnou tinnou commented Jul 2, 2024

Description

When using @requires on a key field selecting a non-key field, our graph composition fails with a stack overflow:

Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at GraphPath.get tail [as tail] (/Users/antoineb/IdeaProjects/federation/query-graphs-js/src/graphPath.ts:199:11)
    at advanceWithOperation (/Users/antoineb/IdeaProjects/federation/query-graphs-js/src/graphPath.ts:2572:28)
    at advanceSimultaneousPathsWithOperation (/Users/antoineb/IdeaProjects/federation/query-graphs-js/src/graphPath.ts:2186:71)
    at ConditionValidationState.advance (/Users/antoineb/IdeaProjects/federation/query-graphs-js/src/conditionsValidation.ts:30:65)
    at resolver (/Users/antoineb/IdeaProjects/federation/query-graphs-js/src/conditionsValidation.ts:114:31)
    at /Users/antoineb/IdeaProjects/federation/query-graphs-js/src/conditionsCaching.ts:39:26
    at canSatisfyConditions (/Users/antoineb/IdeaProjects/federation/query-graphs-js/src/graphPath.ts:2007:22)

I added a unit test to reproduce the issue.
I'm having doubts whether this is actually a legitimate use case of @requires. To me it feels not, and if this is correct, we could probably raise a validation error earlier in the composition process as key fields are either provided by the router or or expected to be provided by the subgraph.

@tinnou tinnou requested a review from a team as a code owner July 2, 2024 19:53
Copy link

netlify bot commented Jul 2, 2024

👷 Deploy request for apollo-federation-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit f4d0b19

Copy link

changeset-bot bot commented Jul 2, 2024

⚠️ No Changeset found

Latest commit: f4d0b19

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

codesandbox-ci bot commented Jul 2, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

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.

1 participant