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

Fix logic for sibling branches when traversing fields #2635

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented Jun 21, 2023

This re-introduce the fix from the commits reverted by #2630.

The FieldsConflictValidator.forField() method currently in main is incorrect: when it traverses a field, it only keeps the one branch for that field, but the subselection of a field needs to merge correctly with the subselection of any other branch that has the same response name. This PR makes sure that all the relevant branches are taken into account.

@pcmanus pcmanus requested a review from a team as a code owner June 21, 2023 09:36
@netlify
Copy link

netlify bot commented Jun 21, 2023

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

Visit the deploys page to approve it

Name Link
🔨 Latest commit 004a2d5

@changeset-bot
Copy link

changeset-bot bot commented Jun 21, 2023

⚠️ No Changeset found

Latest commit: 004a2d5

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 21, 2023

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.

The `FieldsConflictValidator.forField()` method of the previous
patch was incorret: when we traverse a field, we were only keeping
the one branch for that field, but the subselection of a field
needs to merge correctly with the subselection of any other branch
that has the same response name.
@pcmanus pcmanus merged commit fea502a into apollographql:main Jun 28, 2023
pcmanus added a commit to pcmanus/federation that referenced this pull request Aug 18, 2023
…with conflicting fields

Trying to reuse fragments, if done without specific case, can in some context result in invalid
selections due to fields conflicting. It is to avoid that problem that apollographql#2619 introduced the
`FieldsConflictValidator` mechanism (later improved by apollographql#2635).

Unfortunately, in some fairly specific setups with nested fragments, the
code was missing some data in the validation mentioned above, which led
to still having case where a subgraph fetch may be invalid due to some
fields (within reusing fragments) conflicting at some point of the
query.

This commit fix that issue by ensuring we take everything we should into
account when doing the aforementioned validation.
pcmanus pushed a commit that referenced this pull request Aug 21, 2023
…with conflicting fields (#2740)

Trying to reuse fragments, if done without specific case, can in some context result in invalid
selections due to fields conflicting. It is to avoid that problem that #2619 introduced the
`FieldsConflictValidator` mechanism (later improved by #2635).

Unfortunately, in some fairly specific setups with nested fragments, the
code was missing some data in the validation mentioned above, which led
to still having case where a subgraph fetch may be invalid due to some
fields (within reusing fragments) conflicting at some point of the
query.

This commit fix that issue by ensuring we take everything we should into
account when doing the aforementioned validation.
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.

2 participants