Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(apollo-parser): add ignored tokens to TYPE nodes in correct place #153

Merged
merged 2 commits into from
Jan 26, 2022

Conversation

lrlna
Copy link
Member

@lrlna lrlna commented Jan 26, 2022

This re-writes the parsing logic for TYPE nodes to have an easier time accounting for ignored tokens and their correct place in the AST. An intermediate representation of the TYPE and it's nullability and list status is created and then processed to put the correct tokens in their spots.

Before this commit this sort of query

mutation MyMutation($custId: Int!, $b: String) {
  myMutation(custId: $custId)
}

would result the ast.document.to_string() to have this output:

mutation MyMutation($custId: , Int!$b:  String) {
    myMutation(custId: $custId)
}

which is incorrect. The to_string() now results in the exact same output, as the AST created is correct.

fixes #143

@lrlna lrlna self-assigned this Jan 26, 2022
This commit re-writes the parsing logic for TYPE nodes to have an easier time accounting for ignored tokens and their correct place in the AST. An intermediate representation of the TYPE and it's nullability and list status is created and then processed to put the correct tokens in their spots.

Before this commit this sort of query
```graphql
mutation MyMutation($custId: Int!, $b: String) {
  myMutation(custId: $custId)
}
```
would result the `ast.document.to_string()` to have this output:
```graphql
mutation MyMutation($custId: , Int!$b:  String) {
    myMutation(custId: $custId)
}
```
which is incorrect. The `to_string()` now results in the exact same output, as the AST created is correct.
@lrlna lrlna merged commit c95ad06 into main Jan 26, 2022
@lrlna lrlna deleted the 143 branch January 26, 2022 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ast: TYPE (non-null, list and named types) does not preserve ignored characters order
1 participant