Skip to content

Conversation

sungam3r
Copy link
Member

fixes #296

@sungam3r sungam3r requested a review from Shane32 April 20, 2023 12:27
@sungam3r sungam3r self-assigned this Apr 20, 2023
@sungam3r sungam3r added the enhancement New feature or request label Apr 20, 2023
@github-actions github-actions bot added the test Pull request that adds new or changes existing tests label Apr 20, 2023
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

}

internal GraphQLValue ParseValueLiteral(bool isConstant)
public GraphQLValue ParseValueLiteral(bool? isConstant)
Copy link
Member

Choose a reason for hiding this comment

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

I don’t understand why these were changed to nullable booleans or what null does compared to false. Here I don’t see a difference.

Copy link
Member Author

Choose a reason for hiding this comment

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

GraphQLVariable inherits GraphQLValue and I called ParseValueLiteral with true before. In case of GraphQLVariable this method throws. null as a value of isConstant means that caller wants to parse any value - either constant or not (variable).

Copy link
Member Author

@sungam3r sungam3r Apr 20, 2023

Choose a reason for hiding this comment

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

Core difference is here:
изображение

variable will be parsed for false AND null

Copy link
Member

Choose a reason for hiding this comment

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

I still fail to understand why it's not a bool instead of bool?. It seems that null behaves identically to false. Why the change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, it works without ?, reverted.


else if (typeof(T) == typeof(GraphQLValue))
result = (T)(object)context.ParseValueLiteral(true);
result = (T)(object)context.ParseValueLiteral(null);
Copy link
Member

Choose a reason for hiding this comment

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

And here it’s now null. I’m sorta puzzled. Certainly for your use you would need the ability to have this as false, right ? And if false is null then why not false?

Copy link
Member Author

Choose a reason for hiding this comment

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

For my use case I wanted to be able to parse literals, so I wrote true here. Now I added support for parsing variables. Variable inherits GraphQLValue but parser will throw if you call ParseValueLiteral(true) on text $id.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did not change calls inside parser - they all continue to pass either true or false as before. The single place where I pass null is here.

Copy link
Member

Choose a reason for hiding this comment

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

Are you adding something to the API so you can call ParseValueLiteral(true)? Or are you going to write an AST visitor to ensure that the value does not reference a variable?

Copy link
Member Author

Choose a reason for hiding this comment

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

I reverted bool? to bool and now pass false. It works. My bad.

@sungam3r sungam3r merged commit 7b0e9da into master Apr 20, 2023
@sungam3r sungam3r deleted the parse branch April 20, 2023 15:32
@sungam3r
Copy link
Member Author

@Shane32 Are you OK to release v9 after merge?

@Shane32
Copy link
Member

Shane32 commented Apr 20, 2023

@Shane32 Are you OK to release v9 after merge?

Sure

@codecov codecov bot deleted a comment from codecov-commenter Jul 28, 2025
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.23%. Comparing base (8483d95) to head (844b2e3).
⚠️ Report is 73 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
+ Coverage   96.02%   96.23%   +0.20%     
==========================================
  Files          85       85              
  Lines        4835     4889      +54     
  Branches      448      475      +27     
==========================================
+ Hits         4643     4705      +62     
+ Misses        190      184       -6     
+ Partials        2        0       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request test Pull request that adds new or changes existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More Parse methods
2 participants