-
Notifications
You must be signed in to change notification settings - Fork 162
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
Location Lines #51
Comments
I believe the errors are only associated with comments # correct
"{\n name\n}" %>% graphql2json() {"kind":"Document","loc":{"start": {"line": 1,"column":1}, "end": {"line":3,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 1,"column":1}, "end": {"line":3,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 1,"column":1}, "end": {"line":3,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} # incorrect. Document should start on line 2
"#asdfasdf\n{\n name\n}" %>% graphql2json() {"kind":"Document","loc":{"start": {"line": 1,"column":11}, "end": {"line":3,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 1,"column":11}, "end": {"line":3,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 1,"column":11}, "end": {"line":3,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} # incorrect. Document should start on line 2
"#asdfasdf \n{\n name\n}" %>% graphql2json()
```json
{"kind":"Document","loc":{"start": {"line": 1,"column":14}, "end": {"line":3,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 1,"column":14}, "end": {"line":3,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 1,"column":14}, "end": {"line":3,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} # correct
"\n \n \n{\n name\n}" %>% graphql2json() {"kind":"Document","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 5,"column":3}, "end": {"line":5,"column":7}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 5,"column":3}, "end": {"line":5,"column":7}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} # incorrect. Name should start on line 6
"\n \n \n{\n#asdf\n name\n}" %>% graphql2json() {"kind":"Document","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 5,"column":9}, "end": {"line":5,"column":13}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 5,"column":9}, "end": {"line":5,"column":13}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} |
With the location information, should the list of information about the start or end position, have a GraphQL Class? type Position {
line: Int!
column: Int!
}
type Location {
start: Position!
end: Position!
} This would make the output something like: ...
"loc": {
"kind": "Location",
"start": {
"kind": "Position",
"line": 4,
"column": 1
},
"end": {
"kind": "Position",
"line": 6,
"column": 2
}
}
... Thank you for the help! |
There is also some odd length when looking at "{name(id:\"Barret\")}" %>% graphql2json() { "kind":"Document",
"loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":26}},
"definitions":[
{ "kind":"OperationDefinition",
"loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":26}},
"operation":"query",
"name":null,
"variableDefinitions":null,
"directives":null,
"selectionSet":
{ "kind":"SelectionSet",
"loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":26}},
"selections":[
{ "kind":"Field",
"loc":{"start": {"line": 1,"column":2}, "end": {"line":1,"column":25}},
"alias":null,
"name":{"kind":"Name",
"loc":{"start": {"line": 1,"column":2}, "end": {"line":1,"column":6}},
"value":"name"},
"arguments":[
{ "kind":"Argument",
"loc":{"start": {"line": 1,"column":7}, "end": {"line":1,"column":10}},
"name":{ "kind":"Name",
"loc":{"start": {"line": 1,"column":7}, "end": {"line":1,"column":9}},
"value":"id"},
"value":{"kind":"StringValue",
"loc":{"start": {"line": 1,"column":9}, "end": {"line":1,"column":10}},
"value":"Barret"}
}
],
"directives":null,
"selectionSet":null
}]}}]} The same size query below has the correct positions "{name(id:12345678)}" %>% graphql2json() {"kind":"Document",
"loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":20}},
"definitions":[
{ "kind":"OperationDefinition",
"loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":20}},
"operation":"query",
"name":null,
"variableDefinitions":null,
"directives":null,
"selectionSet":{"kind":"SelectionSet",
"loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":20}},
"selections":[
{ "kind":"Field",
"loc":{"start": {"line": 1,"column":2}, "end": {"line":1,"column":19}},
"alias":null,
"name":{"kind":"Name",
"loc":{"start": {"line": 1,"column":2}, "end": {"line":1,"column":6}},
"value":"name"},
"arguments":[
{ "kind":"Argument",
"loc":{"start": {"line": 1,"column":7}, "end": {"line":1,"column":18}},
"name":{"kind":"Name",
"loc":{"start": {"line": 1,"column":7}, "end": {"line":1,"column":9}},
"value":"id"},
"value":{"kind":"IntValue",
"loc":{"start": {"line": 1,"column":10}, "end": {"line":1,"column":18}},
"value":"12345678"}
}
],
"directives":null,
"selectionSet":null
}]}}]} |
I think this was fixed by #52. |
I'm looking at the location values for https://github.com/graphql/libgraphqlparser/blob/master/test/schema-kitchen-sink.json and https://github.com/graphql/libgraphqlparser/blob/master/test/kitchen-sink.json.
Both the kitchen sink (request) and schema kitchen sink GraphQL test inputs have comments and white space for the first 7-8 lines. But the locations in the JSON output say the documents start at line 2 and finish before the definitions are done.
Does libgraphqlparser remove comment only lines? The JSON locations do not match the original text definition locations. (Trying to make my print statements match the error information)
(Thank you for the line number addition!)
The text was updated successfully, but these errors were encountered: