Skip to content

Instantly share code, notes, and snippets.

@aarvay
Created February 21, 2016 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarvay/1a47aa0200d6d3c773ec to your computer and use it in GitHub Desktop.
Save aarvay/1a47aa0200d6d3c773ec to your computer and use it in GitHub Desktop.
libgraphqlparser's ast_to_json()issue
{
"kind": "Document",
"loc": {
"start": 1,
"end": 2
},
"definitions": [
{
"kind": "OperationDefinition",
"loc": {
"start": 1,
"end": 2
},
"operation": "query",
"name": {
"kind": "Name",
"loc": {
"start": 7,
"end": 16
},
"value": "queryName"
},
"variableDefinitions": [
{
"kind": "VariableDefinition",
"loc": {
"start": 17,
"end": 34
},
"variable": {
"kind": "Variable",
"loc": {
"start": 17,
"end": 21
},
"name": {
"kind": "Name",
"loc": {
"start": 17,
"end": 21
},
"value": "foo"
}
},
"type": {
"kind": "NamedType",
"loc": {
"start": 23,
"end": 34
},
"name": {
"kind": "Name",
"loc": {
"start": 23,
"end": 34
},
"value": "ComplexType"
}
},
"defaultValue": null
},
{
"kind": "VariableDefinition",
"loc": {
"start": 36,
"end": 56
},
"variable": {
"kind": "Variable",
"loc": {
"start": 36,
"end": 41
},
"name": {
"kind": "Name",
"loc": {
"start": 36,
"end": 41
},
"value": "site"
}
},
"type": {
"kind": "NamedType",
"loc": {
"start": 43,
"end": 47
},
"name": {
"kind": "Name",
"loc": {
"start": 43,
"end": 47
},
"value": "Site"
}
},
"defaultValue": {
"kind": "EnumValue",
"loc": {
"start": 50,
"end": 56
},
"value": "MOBILE"
}
}
],
"directives": null,
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 58,
"end": 2
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 3,
"end": 4
},
"alias": {
"kind": "Name",
"loc": {
"start": 3,
"end": 15
},
"value": "whoever123is"
},
"name": {
"kind": "Name",
"loc": {
"start": 17,
"end": 21
},
"value": "node"
},
"arguments": [
{
"kind": "Argument",
"loc": {
"start": 22,
"end": 36
},
"name": {
"kind": "Name",
"loc": {
"start": 22,
"end": 24
},
"value": "id"
},
"value": {
"kind": "ArrayValue",
"loc": {
"start": 26,
"end": 36
},
"values": [
{
"kind": "IntValue",
"loc": {
"start": 27,
"end": 30
},
"value": "123"
},
{
"kind": "IntValue",
"loc": {
"start": 32,
"end": 35
},
"value": "456"
}
]
}
}
],
"directives": null,
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 38,
"end": 4
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 5,
"end": 7
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 5,
"end": 7
},
"value": "id"
},
"arguments": null,
"directives": null,
"selectionSet": null
},
{
"kind": "InlineFragment",
"loc": {
"start": 5,
"end": 6
},
"typeCondition": {
"kind": "NamedType",
"loc": {
"start": 12,
"end": 16
},
"name": {
"kind": "Name",
"loc": {
"start": 12,
"end": 16
},
"value": "User"
}
},
"directives": [
{
"kind": "Directive",
"loc": {
"start": 17,
"end": 23
},
"name": {
"kind": "Name",
"loc": {
"start": 18,
"end": 23
},
"value": "defer"
},
"arguments": null
}
],
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 24,
"end": 6
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 7,
"end": 8
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 7,
"end": 13
},
"value": "field2"
},
"arguments": null,
"directives": null,
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 14,
"end": 8
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 9,
"end": 11
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 9,
"end": 11
},
"value": "id"
},
"arguments": null,
"directives": null,
"selectionSet": null
},
{
"kind": "Field",
"loc": {
"start": 9,
"end": 10
},
"alias": {
"kind": "Name",
"loc": {
"start": 9,
"end": 14
},
"value": "alias"
},
"name": {
"kind": "Name",
"loc": {
"start": 16,
"end": 22
},
"value": "field1"
},
"arguments": [
{
"kind": "Argument",
"loc": {
"start": 23,
"end": 31
},
"name": {
"kind": "Name",
"loc": {
"start": 23,
"end": 28
},
"value": "first"
},
"value": {
"kind": "IntValue",
"loc": {
"start": 29,
"end": 31
},
"value": "10"
}
},
{
"kind": "Argument",
"loc": {
"start": 33,
"end": 43
},
"name": {
"kind": "Name",
"loc": {
"start": 33,
"end": 38
},
"value": "after"
},
"value": {
"kind": "Variable",
"loc": {
"start": 39,
"end": 43
},
"name": {
"kind": "Name",
"loc": {
"start": 39,
"end": 43
},
"value": "foo"
}
}
}
],
"directives": [
{
"kind": "Directive",
"loc": {
"start": 46,
"end": 64
},
"name": {
"kind": "Name",
"loc": {
"start": 47,
"end": 54
},
"value": "include"
},
"arguments": [
{
"kind": "Argument",
"loc": {
"start": 55,
"end": 63
},
"name": {
"kind": "Name",
"loc": {
"start": 55,
"end": 57
},
"value": "if"
},
"value": {
"kind": "Variable",
"loc": {
"start": 59,
"end": 63
},
"name": {
"kind": "Name",
"loc": {
"start": 59,
"end": 63
},
"value": "foo"
}
}
}
]
}
],
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 65,
"end": 10
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 11,
"end": 13
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 11,
"end": 13
},
"value": "id"
},
"arguments": null,
"directives": null,
"selectionSet": null
},
{
"kind": "FragmentSpread",
"loc": {
"start": 11,
"end": 18
},
"name": {
"kind": "Name",
"loc": {
"start": 14,
"end": 18
},
"value": "frag"
},
"directives": null
}
]
}
}
]
}
}
]
}
},
{
"kind": "InlineFragment",
"loc": {
"start": 5,
"end": 6
},
,
"directives": [
{
"kind": "Directive",
"loc": {
"start": 9,
"end": 28
},
"name": {
"kind": "Name",
"loc": {
"start": 10,
"end": 14
},
"value": "skip"
},
"arguments": [
{
"kind": "Argument",
"loc": {
"start": 15,
"end": 27
},
"name": {
"kind": "Name",
"loc": {
"start": 15,
"end": 21
},
"value": "unless"
},
"value": {
"kind": "Variable",
"loc": {
"start": 23,
"end": 27
},
"name": {
"kind": "Name",
"loc": {
"start": 23,
"end": 27
},
"value": "foo"
}
}
}
]
}
],
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 29,
"end": 6
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 7,
"end": 9
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 7,
"end": 9
},
"value": "id"
},
"arguments": null,
"directives": null,
"selectionSet": null
}
]
}
},
{
"kind": "InlineFragment",
"loc": {
"start": 5,
"end": 6
},
,
"directives": null,
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 9,
"end": 6
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 7,
"end": 9
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 7,
"end": 9
},
"value": "id"
},
"arguments": null,
"directives": null,
"selectionSet": null
}
]
}
}
]
}
}
]
}
},
{
"kind": "OperationDefinition",
"loc": {
"start": 1,
"end": 2
},
"operation": "mutation",
"name": {
"kind": "Name",
"loc": {
"start": 10,
"end": 19
},
"value": "likeStory"
},
"variableDefinitions": null,
"directives": null,
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 20,
"end": 2
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 3,
"end": 4
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 3,
"end": 7
},
"value": "like"
},
"arguments": [
{
"kind": "Argument",
"loc": {
"start": 8,
"end": 18
},
"name": {
"kind": "Name",
"loc": {
"start": 8,
"end": 13
},
"value": "story"
},
"value": {
"kind": "IntValue",
"loc": {
"start": 15,
"end": 18
},
"value": "123"
}
}
],
"directives": [
{
"kind": "Directive",
"loc": {
"start": 20,
"end": 26
},
"name": {
"kind": "Name",
"loc": {
"start": 21,
"end": 26
},
"value": "defer"
},
"arguments": null
}
],
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 27,
"end": 4
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 5,
"end": 6
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 5,
"end": 10
},
"value": "story"
},
"arguments": null,
"directives": null,
"selectionSet": {
"kind": "SelectionSet",
"loc": {
"start": 11,
"end": 6
},
"selections": [
{
"kind": "Field",
"loc": {
"start": 7,
"end": 9
},
"alias": null,
"name": {
"kind": "Name",
"loc": {
"start": 7,
"end": 9
},
"value": "id"
},
"arguments": null,
"directives": null,
"selectionSet": null
}
]
}
}
]
}
}
]
}
}
]
}
query queryName($foo: ComplexType, $site: Site = MOBILE) {
whoever123is: node(id: [123, 456]) {
id ,
... on User @defer {
field2 {
id ,
alias: field1(first:10, after:$foo,) @include(if: $foo) {
id,
...frag
}
}
}
... @skip(unless: $foo) {
id
}
... {
id
}
}
}
mutation likeStory {
like(story: 123) @defer {
story {
id
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment