Skip to content

Some AST consistency questions #729

Closed
@stubailo

Description

@stubailo

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:

name: null,

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions