-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: Field alias completions #4135
Closed
beaumontjonathan
wants to merge
7
commits into
facebook:main
from
beaumontjonathan:jb_field-alias-completions
Closed
Fix: Field alias completions #4135
beaumontjonathan
wants to merge
7
commits into
facebook:main
from
beaumontjonathan:jb_field-alias-completions
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alunyov
requested changes
Nov 23, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this change!
Can you add a test with the updated error message?
@alunyov Fair comment, I've added a test 😄 |
@alunyov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
zth
pushed a commit
to zth/relay
that referenced
this pull request
Nov 30, 2022
Summary: # Fix field alias completions The parser currently stops parsing documents when it encounters incomplete aliases, e.g., ```graphql query { user { aliasField: # Expected a non-variable identifier (e.g. 'x' or 'Foo') } } ``` It reports that it's expecting an identifier, which is the correct error, but reports it on the span of the next token. ## Changes: - stops the parser from exiting early by placing reporting an error then placing an empty identifier in the tree - adds a more verbose error message - refactor: added new helper `fn empty_identifier(&self) -> Identifier` on `Parser` because now 3 places are making use of this "empty identifier" & record error pattern ## Before <img width="912" alt="Screenshot 2022-11-22 at 23 00 50" src="https://user-images.githubusercontent.com/17055343/203438640-e1e522f5-6d35-4682-9a6b-6d4e6487593d.png"> #### Before (error message visible) <img width="912" alt="Screenshot 2022-11-22 at 23 00 12" src="https://user-images.githubusercontent.com/17055343/203438644-88bf0339-3d26-4c0a-9f3b-f41e4d5568a0.png"> ## After <img width="912" alt="Screenshot 2022-11-22 at 22 57 56" src="https://user-images.githubusercontent.com/17055343/203438647-e4558b3a-9a88-457d-bcd7-47f53c96f65b.png"> Now that parsing continues, multiple errors can be reported whereas previously the parser would bail at the first invalid alias <img width="949" alt="Screenshot 2022-11-23 at 10 15 10" src="https://user-images.githubusercontent.com/17055343/203521931-e6bb9adc-2b20-4a16-bc8b-08ef8f013799.png"> Pull Request resolved: facebook#4135 Reviewed By: tyao1 Differential Revision: D41505486 Pulled By: alunyov fbshipit-source-id: 0f776badd05819b189b6d945785b86754db26418
zth
pushed a commit
to zth/relay
that referenced
this pull request
Nov 30, 2022
Summary: # Fix field alias completions The parser currently stops parsing documents when it encounters incomplete aliases, e.g., ```graphql query { user { aliasField: # Expected a non-variable identifier (e.g. 'x' or 'Foo') } } ``` It reports that it's expecting an identifier, which is the correct error, but reports it on the span of the next token. ## Changes: - stops the parser from exiting early by placing reporting an error then placing an empty identifier in the tree - adds a more verbose error message - refactor: added new helper `fn empty_identifier(&self) -> Identifier` on `Parser` because now 3 places are making use of this "empty identifier" & record error pattern ## Before <img width="912" alt="Screenshot 2022-11-22 at 23 00 50" src="https://user-images.githubusercontent.com/17055343/203438640-e1e522f5-6d35-4682-9a6b-6d4e6487593d.png"> #### Before (error message visible) <img width="912" alt="Screenshot 2022-11-22 at 23 00 12" src="https://user-images.githubusercontent.com/17055343/203438644-88bf0339-3d26-4c0a-9f3b-f41e4d5568a0.png"> ## After <img width="912" alt="Screenshot 2022-11-22 at 22 57 56" src="https://user-images.githubusercontent.com/17055343/203438647-e4558b3a-9a88-457d-bcd7-47f53c96f65b.png"> Now that parsing continues, multiple errors can be reported whereas previously the parser would bail at the first invalid alias <img width="949" alt="Screenshot 2022-11-23 at 10 15 10" src="https://user-images.githubusercontent.com/17055343/203521931-e6bb9adc-2b20-4a16-bc8b-08ef8f013799.png"> Pull Request resolved: facebook#4135 Reviewed By: tyao1 Differential Revision: D41505486 Pulled By: alunyov fbshipit-source-id: 0f776badd05819b189b6d945785b86754db26418
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix field alias completions
The parser currently stops parsing documents when it encounters incomplete aliases, e.g.,
It reports that it's expecting an identifier, which is the correct error, but reports it on the span of the next token.
Changes:
fn empty_identifier(&self) -> Identifier
onParser
because now 3 places are making use of this "empty identifier" & record error patternBefore
Before (error message visible)
After
Now that parsing continues, multiple errors can be reported whereas previously the parser would bail at the first invalid alias