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 merged source name generation when shared root is operation root #3073

Merged
merged 2 commits into from
Jun 14, 2023

Conversation

AnthonyMDev
Copy link
Contributor

This fixes #3071

When the shared root of a merged source is the direct parent or a direct sibling, we remove the parent from the namespacing of the referenced selection set. If the shared root is the root of the operation/fragment, that component of the namespacing should be removed.

Since the change to the way we indicate the location of a SelectionSet in the IR changed in #3045, in this case, the shared root is now not part of the fieldPath, causing the "shared root" to be at an index of -1 (because its represented by the location.source now). This was causing a crash with an invalid range bounds.

This PR fixes this by using max(0, sharedRootIndex) to ensure we don't use -1, and then not removing the first component in that case (because that component would be the location.source which is already not included.

@netlify
Copy link

netlify bot commented Jun 14, 2023

Deploy Preview for apollo-ios-docs canceled.

Name Link
🔨 Latest commit 889a958
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docs/deploys/648a3bb2efd06200089a8e4d

Copy link
Member

@calvincestari calvincestari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AnthonyMDev 🎉

@AnthonyMDev AnthonyMDev merged commit ff49bec into main Jun 14, 2023
@AnthonyMDev AnthonyMDev deleted the codegen-mergedsources-crash branch June 14, 2023 23:47
@AnthonyMDev AnthonyMDev mentioned this pull request Jun 15, 2023
7 tasks
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.

Code generation throwing an error in 1.2.1 only
2 participants