I'm currently working on some AST stuff, and I'm running into a few situations where there is different behavior in a way that doesn't seem intentional. Two examples so far:
Operation name
returns "name": undefined in the operation definition.
returns "name": null in the operation definition.
Variable definitions
returns "variableDefinitions": [] in the operation definition.
returns "variableDefinitions": null in the operation definition.
Conclusion
Looks like these two in particular are because of this line and similar ones that hardcode the default values:
@leebyron - Would you be interested in a PR to make these different situations consistent, for example to always return null for the operation name and [] for variable definitions?
I'd be happy to submit a PR with all of the situations I find, but first wanted to check if that would be desirable - I can imagine some tools might depend on this output not changing.
I'm currently working on some AST stuff, and I'm running into a few situations where there is different behavior in a way that doesn't seem intentional. Two examples so far:
Operation name
returns
"name": undefinedin the operation definition.returns
"name": nullin the operation definition.Variable definitions
returns
"variableDefinitions": []in the operation definition.returns
"variableDefinitions": nullin the operation definition.Conclusion
Looks like these two in particular are because of this line and similar ones that hardcode the default values:
graphql-js/src/language/parser.js
Line 275 in b17d5f5
@leebyron - Would you be interested in a PR to make these different situations consistent, for example to always return
nullfor the operation name and[]for variable definitions?I'd be happy to submit a PR with all of the situations I find, but first wanted to check if that would be desirable - I can imagine some tools might depend on this output not changing.