Skip to content

Parse equality is whitespace dependent #71

Closed
@AlecAivazis

Description

@AlecAivazis

@syrusakbary - I'm trying to test the generation of graphql queries by using graphql.parse and experiencing some weird behavior:

import graphql
print(graphql.parse("""
    query {
        user(id: 1) { foo {
                bar(arg:"2") {
                    id
                }
            }
        }
    }
""") == graphql.parse("""
    query {
        user(id: 1) { foo { bar(arg:"2") {
                    id
                }
            }
        }
    }
"""))
# prints false

The only difference between these two queries is the position of the bar node but the individual results look identical:

print(graphql.parse("""
    query {
        user(id: 1) { foo {
                bar(arg:"2") {
                    id
                }
            }
        }
    }
"""))
# prints Document(definitions=[OperationDefinition(operation='query', name=None, variable_definitions=[], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value='user'), arguments=[Argument(name=Name(value='id'), value=IntValue(value='1'))], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value='foo'), arguments=[], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value='bar'), arguments=[Argument(name=Name(value='arg'), value=StringValue(value='2'))], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value='id'), arguments=[], directives=[], selection_set=None)]))]))]))]))])

print(graphql.parse("""
    query {
        user(id: 1) { foo { bar(arg:"2") {
                    id
                }
            }
        }
    }
"""))
# prints Document(definitions=[OperationDefinition(operation='query', name=None, variable_definitions=[], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value='user'), arguments=[Argument(name=Name(value='id'), value=IntValue(value='1'))], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value='foo'), arguments=[], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value='bar'), arguments=[Argument(name=Name(value='arg'), value=StringValue(value='2'))], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value='id'), arguments=[], directives=[], selection_set=None)]))]))]))]))])

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