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(biome_graphql_parser): allow keyword to be used as identifier #2814

Merged
merged 1 commit into from May 13, 2024

Conversation

vohoanglong0107
Copy link
Contributor

@vohoanglong0107 vohoanglong0107 commented May 11, 2024

Summary

It's hard to believe, but GraphQL allows using keyword as identifier. This means that the parser must be able to handle a GraphQL query like this:

query enum($true: false) {
  null
  mutation
  enum Direction @deprecated {
    NORTH
    WEST
  }
}

This means many assumptions made when handling parsing errors are no longer applicable. In the above example, suppose the query misses the closing brace:

query enum($true: false) {
  null
  mutation
  enum Direction @deprecated {
    NORTH
    WEST
  }

This could either mean the entire expression is a giant query, or there is a query and an enum definition, depending on where the users want to put the closing braces.

This PR adds support for using keywords as identifier, and removes several assumptions made when handling errors.

Test Plan

All tests should pass.

@vohoanglong0107 vohoanglong0107 force-pushed the fix-allow-key-word-as-name branch 2 times, most recently from b1bed33 to 47199ea Compare May 12, 2024 23:46
@github-actions github-actions bot added the A-Parser Area: parser label May 12, 2024
Copy link

codspeed-hq bot commented May 13, 2024

CodSpeed Performance Report

Merging #2814 will not alter performance

Comparing vohoanglong0107:fix-allow-key-word-as-name (e628d87) with main (ec69b81)

Summary

✅ 97 untouched benchmarks

@vohoanglong0107 vohoanglong0107 marked this pull request as ready for review May 13, 2024 00:39
@ematipico ematipico merged commit 7095ed0 into biomejs:main May 13, 2024
12 checks passed
@vohoanglong0107 vohoanglong0107 deleted the fix-allow-key-word-as-name branch May 13, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Parser Area: parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants