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

erroneous spans when an error is created with err_and_pop #325

Closed
lrlna opened this issue Oct 18, 2022 · 1 comment
Closed

erroneous spans when an error is created with err_and_pop #325

lrlna opened this issue Oct 18, 2022 · 1 comment
Assignees
Labels
apollo-parser bug Something isn't working

Comments

@lrlna
Copy link
Member

lrlna commented Oct 18, 2022

Our error spans are inconsistent when an error is created with err_and_pop.

A few examples.
GraphQL:

cats
# comment

Document:

- DOCUMENT@0..10
    - WHITESPACE@0..1 "\n"
    - COMMENT@1..10 "# comment"
- ERROR@0:4 "expected definition" cats

GraphQL:

cats

type Query {
    name: String
}

Document:

- DOCUMENT@0..33
    - WHITESPACE@0..2 "\n\n"
    - OBJECT_TYPE_DEFINITION@2..33
        - type_KW@2..6 "type"
        - WHITESPACE@6..7 " "
        - NAME@7..13
            - IDENT@7..12 "Query"
            - WHITESPACE@12..13 " "
        - FIELDS_DEFINITION@13..33
            - L_CURLY@13..14 "{"
            - WHITESPACE@14..19 "\n    "
            - FIELD_DEFINITION@19..32
                - NAME@19..23
                    - IDENT@19..23 "name"
                - COLON@23..24 ":"
                - WHITESPACE@24..25 " "
                - NAMED_TYPE@25..31
                    - NAME@25..31
                        - IDENT@25..31 "String"
                - WHITESPACE@31..32 "\n"
            - R_CURLY@32..33 "}"
- ERROR@0:4 "expected definition" cats

This no longer becomes the case when the error precedes a valid statement, so if we reverse the two statements above:

type Query {
    name: String
}

cats

Our Document's spans are then correct:

- DOCUMENT@0..33
    - OBJECT_TYPE_DEFINITION@0..33
        - type_KW@0..4 "type"
        - WHITESPACE@4..5 " "
        - NAME@5..11
            - IDENT@5..10 "Query"
            - WHITESPACE@10..11 " "
        - FIELDS_DEFINITION@11..33
            - L_CURLY@11..12 "{"
            - WHITESPACE@12..17 "\n    "
            - FIELD_DEFINITION@17..30
                - NAME@17..21
                    - IDENT@17..21 "name"
                - COLON@21..22 ":"
                - WHITESPACE@22..23 " "
                - NAMED_TYPE@23..29
                    - NAME@23..29
                        - IDENT@23..29 "String"
                - WHITESPACE@29..30 "\n"
            - R_CURLY@30..31 "}"
            - WHITESPACE@31..33 "\n\n"
- ERROR@33:37 "expected definition" cats

Initially found in #324

@lrlna lrlna added bug Something isn't working apollo-parser labels Oct 18, 2022
@goto-bus-stop goto-bus-stop self-assigned this Nov 3, 2022
goto-bus-stop added a commit that referenced this issue Feb 3, 2023
goto-bus-stop added a commit that referenced this issue Feb 3, 2023
@goto-bus-stop
Copy link
Member

Closing this in favour of follow-ups: #450 and #451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apollo-parser bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants