public function testInspectionQuery()
{
$parser = new Parser();
$data = $parser->parse('
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
types {
...FullType
}
directives {
name
description
args {
...InputValue
}
onOperation
onFragment
onField
}
}
}
fragment FullType on __Type {
kind
name
description
fields {
name
description
args {
...InputValue
}
type {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
type { ...TypeRef }
defaultValue
}
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
');
$this->assertEquals(['queries' => [new Query('__schema', null, [], [new Query('queryType', null, [], [new Field('name', null, [], new Location(4, 33))], new Location(4, 21)), new Query('mutationType', null, [], [new Field('name', null, [], new Location(5, 36))], new Location(5, 21)), new Query('types', null, [], [new FragmentReference('FullType', new Location(7, 28))], new Location(6, 21)), new Query('directives', null, [], [new Field('name', null, [], new Location(10, 25)), new Field('description', null, [], new Location(11, 25)), new Query('args', null, [], [new FragmentReference('InputValue', new Location(13, 32))], new Location(12, 25)), new Field('onOperation', null, [], new Location(15, 25)), new Field('onFragment', null, [], new Location(16, 25)), new Field('onField', null, [], new Location(17, 25))], new Location(9, 21))], new Location(3, 17))], 'mutations' => [], 'fragments' => [new Fragment('FullType', '__Type', [new Field('kind', null, [], new Location(23, 17)), new Field('name', null, [], new Location(24, 17)), new Field('description', null, [], new Location(25, 17)), new Query('fields', null, [], [new Field('name', null, [], new Location(27, 21)), new Field('description', null, [], new Location(28, 21)), new Query('args', null, [], [new FragmentReference('InputValue', new Location(30, 28))], new Location(29, 21)), new Query('type', null, [], [new FragmentReference('TypeRef', new Location(33, 28))], new Location(32, 21)), new Field('isDeprecated', null, [], new Location(35, 21)), new Field('deprecationReason', null, [], new Location(36, 21))], new Location(26, 17)), new Query('inputFields', null, [], [new FragmentReference('InputValue', new Location(39, 24))], new Location(38, 17)), new Query('interfaces', null, [], [new FragmentReference('TypeRef', new Location(42, 24))], new Location(41, 17)), new Query('enumValues', null, [], [new Field('name', null, [], new Location(45, 21)), new Field('description', null, [], new Location(46, 21)), new Field('isDeprecated', null, [], new Location(47, 21)), new Field('deprecationReason', null, [], new Location(48, 21))], new Location(44, 17)), new Query('possibleTypes', null, [], [new FragmentReference('TypeRef', new Location(51, 24))], new Location(50, 17))], new Location(22, 22)), new Fragment('InputValue', '__InputValue', [new Field('name', null, [], new Location(56, 17)), new Field('description', null, [], new Location(57, 17)), new Query('type', null, [], [new FragmentReference('TypeRef', new Location(58, 27))], new Location(58, 17)), new Field('defaultValue', null, [], new Location(59, 17))], new Location(55, 22)), new Fragment('TypeRef', '__Type', [new Field('kind', null, [], new Location(63, 17)), new Field('name', null, [], new Location(64, 17)), new Query('ofType', null, [], [new Field('kind', null, [], new Location(66, 21)), new Field('name', null, [], new Location(67, 21)), new Query('ofType', null, [], [new Field('kind', null, [], new Location(69, 25)), new Field('name', null, [], new Location(70, 25)), new Query('ofType', null, [], [new Field('kind', null, [], new Location(72, 29)), new Field('name', null, [], new Location(73, 29))], new Location(71, 25))], new Location(68, 21))], new Location(65, 17))], new Location(62, 22))], 'fragmentReferences' => [new FragmentReference('FullType', new Location(7, 28)), new FragmentReference('InputValue', new Location(13, 32)), new FragmentReference('InputValue', new Location(30, 28)), new FragmentReference('TypeRef', new Location(33, 28)), new FragmentReference('InputValue', new Location(39, 24)), new FragmentReference('TypeRef', new Location(42, 24)), new FragmentReference('TypeRef', new Location(51, 24)), new FragmentReference('TypeRef', new Location(58, 27))], 'variables' => [], 'variableReferences' => []], $data);
}