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 operation names #1568

Merged
merged 3 commits into from
Mar 8, 2022
Merged

Fix operation names #1568

merged 3 commits into from
Mar 8, 2022

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented Mar 7, 2022

This is a followup to #1550: as mentioned in my last comment, that PR adds the subgraph names to the operation name, but we unfortunately allow near anything as a subgraph name, and so in particular we can have subgraph names that are invalid graphQL names. in which case the query plan we generate ends up invalid.

This PR "sanitize" the subgraph name (the other part we use for the operation name is the name of the original query, but we know that is a valid graphQL name by definition). It also switch from a single _ to __ to separate the elements from the generate operation names so it's a bit clearer if some underscores are already used for either the original query name or the subgraph name.

@pcmanus pcmanus requested a review from benweatherman March 7, 2022 16:29
@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 7, 2022

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.

Copy link
Contributor

@benweatherman benweatherman left a comment

Choose a reason for hiding this comment

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

Added some unimportant comments but all looks great to me!

query-planner-js/src/buildPlan.ts Outdated Show resolved Hide resolved
query-planner-js/src/buildPlan.ts Show resolved Hide resolved
@pcmanus pcmanus merged commit 6f930d5 into main Mar 8, 2022
@pcmanus pcmanus deleted the fix-operation-names branch March 8, 2022 08:44
pcmanus pushed a commit that referenced this pull request Mar 8, 2022
Followup to #1568, where I misread the documentation of the `replace`
function, expecting it to replace all occurrences when it doesn't
(unless using a regexp with the `g` flag, which this patch does).
trevor-scheer added a commit that referenced this pull request Mar 16, 2022
trevor-scheer added a commit that referenced this pull request Mar 17, 2022
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