Comments (4)
I think this was fixed by #52.
from libgraphqlparser.
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}]}}]}
from libgraphqlparser.
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!
from libgraphqlparser.
There is also some odd length when looking at StringValue
s. The StringValue below should have a position of 1:10 to 1:18. Likewise, the overall Document positions are off.
"{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
}]}}]}
from libgraphqlparser.
Related Issues (20)
- Why not use PEGTL instead?
- New version? HOT 8
- SONAME versioning
- Parsing query with variables HOT 1
- Compilation failed for libgraphqlparser (graphqlparser & lexer.cpp) HOT 2
- Update master to main
- Improve Readme?
- Create release to include bugfixes resolved on master HOT 1
- graphqlparser_bison: parser.ypp:8.10-12: error: invalid version requirement: 3 HOT 2
- Getting undefined reference error when trying to compile dump_json_ast.cpp
- Missing support for extending interfaces
- Missing support for types implementing multiple interfaces HOT 1
- Locations not properly updated when parsing multi-line block strings
- CONTRIBUTING.md still mentions license to be BSD HOT 1
- Checked in Flex / Bison files are under GPL license HOT 3
- Build fails with latest ctypesgen HOT 1
- Missing support for extending schemas
- Remove "facebook" namespace from cpp? HOT 1
- Missing support for extending interfaces
- Missing support for extending input object types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libgraphqlparser.