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

Handle operation parsing error GraphQL #2434

Merged

Conversation

vohoanglong0107
Copy link
Contributor

Summary

Handle parsing for operation in GraphQL parser

Test Plan

All the tests should pass

Copy link

netlify bot commented Apr 13, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit 797b369
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/661ccbde8927ea0008f4d7de
😎 Deploy Preview https://deploy-preview-2434--biomejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 3 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codspeed-hq bot commented Apr 13, 2024

CodSpeed Performance Report

Merging #2434 will not alter performance

Comparing vohoanglong0107:feat-graphql-error-parse-operation (797b369) with main (60dbf5f)

Summary

✅ 93 untouched benchmarks

@vohoanglong0107 vohoanglong0107 force-pushed the feat-graphql-error-parse-operation branch from 5cc07f8 to 79e3871 Compare April 15, 2024 06:15
@vohoanglong0107 vohoanglong0107 force-pushed the feat-graphql-error-parse-operation branch from 79e3871 to 83949bf Compare April 15, 2024 06:31
@vohoanglong0107 vohoanglong0107 marked this pull request as ready for review April 15, 2024 06:38
@vohoanglong0107 vohoanglong0107 marked this pull request as draft April 15, 2024 06:39
@vohoanglong0107 vohoanglong0107 force-pushed the feat-graphql-error-parse-operation branch from 83949bf to 797b369 Compare April 15, 2024 06:40
@vohoanglong0107 vohoanglong0107 marked this pull request as ready for review April 15, 2024 06:59
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

It seems that the parser can't correctly recover itself when parsing broken directives, and it keeps creating bogus nodes. We should review that part, otherwise we risk to create a CST bigger than it should be

Comment on lines +106 to +109
GraphqlBogus {
items: [
GraphqlBogus {
items: [
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem right: two bogus nodes with two items

Plus, we already have GraphqlBogusSelection. I am not sure what's the recovery strategy at the moment

Copy link
Contributor Author

@vohoanglong0107 vohoanglong0107 Apr 16, 2024

Choose a reason for hiding this comment

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

The reason there is a nested bogus nodes here was because in this case:

{
  hero @deprecated(: "Deprecated")
}

The parser tried to parse (: "Deprecated") as an GraphqlArgumentList, but since this argument list has an invalid argument : "Deprecated" the entire list was turn into a bogus node, which caused @deprecated(: "Deprecated") to turn from a GraphqlDirective to a bogus node (as it contained an bogus node instead of an argument list), which turned hero @deprecated(: "Deprecated") from a GraphqlField to a bogus node, caused a series of nested bogus nodes. Do you have any suggestions on how to improve this?

Comment on lines +114 to +120
GraphqlBogus {
items: [
[email protected] "(" [] [],
GraphqlBogus {
items: [
GraphqlBogus {
items: [
Copy link
Member

Choose a reason for hiding this comment

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

Same here. Ideally we should have a better recovering strategy

Comment on lines +253 to +265
},
GraphqlBogus {
items: [
GraphqlBogus {
items: [
[email protected] "@" [] [],
GraphqlBogus {
items: [
[email protected] "(" [] [],
GraphqlBogus {
items: [
GraphqlBogus {
items: [
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should have smaller cases to better evaluate the recovery strategy. The parser seems to not know that is in recovery mode and keeps creating bogus nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It the same issue with the above but with this case:

{
  hero @(: "Deprecated"
}

@ematipico ematipico merged commit b584a88 into biomejs:main Apr 18, 2024
15 checks passed
@vohoanglong0107 vohoanglong0107 deleted the feat-graphql-error-parse-operation branch April 18, 2024 08:52
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