Composition issue infinite recursion with @requires use
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.
Deploy request for apollo-federation-docs pending review.
Visit the deploys page to approve it
| Name | Link |
|---|---|
| Latest commit | f4d0b19bf0aa80f39f0138018baa7f9b4e4e302d |
⚠️ No Changeset found
Latest commit: f4d0b19bf0aa80f39f0138018baa7f9b4e4e302d
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
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.