Description
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
parse(`query { x }`);
returns "name": undefined
in the operation definition.
parse(`{ x }`);
returns "name": null
in the operation definition.
Variable definitions
parse(`query { x }`);
returns "variableDefinitions": []
in the operation definition.
parse(`{ x }`);
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:
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 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.