You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems a bit counter-intuitive to me, and would require me to write some custom parsing code on top of the existing parsing that graphql-js does.
Is this an intentional decision to store the values in a string instead of a number, or is it something that should be changed?
The text was updated successfully, but these errors were encountered:
The parser will always parse the raw-value as a string and hence put it in the AST that way, you can use valueFromAST or valueFromASTUntyped to correctly have this coerced for you.
It also looks like the GraphQL specification defines all literal values, including integers, as strings. This enables reliably parsing and serializing integers and floats across different programming languages and environments.
Using the AST provided by the library, I'm doing some introspection on the queries to extract the default values passed in to a query.
I noticed that the
IntValueNode
andFloatValueNode
types both usestring
to store the value instead ofnumber
.graphql-js/src/language/ast.ts
Lines 478 to 482 in 2aedf25
graphql-js/src/language/ast.ts
Lines 484 to 488 in 2aedf25
This seems a bit counter-intuitive to me, and would require me to write some custom parsing code on top of the existing parsing that graphql-js does.
Is this an intentional decision to store the values in a string instead of a number, or is it something that should be changed?
The text was updated successfully, but these errors were encountered: