@@ -92,14 +92,15 @@ public function printAST(Node $node): string
92
92
}
93
93
94
94
/** @throws \JsonException */
95
- protected function p (?Node $ node, bool $ isDescription = false ): string
95
+ protected function p (?Node $ node ): string
96
96
{
97
97
if ($ node === null ) {
98
98
return '' ;
99
99
}
100
100
101
101
switch (true ) {
102
102
case $ node instanceof ArgumentNode:
103
+ case $ node instanceof ObjectFieldNode:
103
104
return $ this ->p ($ node ->name ) . ': ' . $ this ->p ($ node ->value );
104
105
105
106
case $ node instanceof BooleanValueNode:
@@ -166,6 +167,9 @@ protected function p(?Node $node, bool $isDescription = false): string
166
167
);
167
168
168
169
case $ node instanceof EnumValueNode:
170
+ case $ node instanceof FloatValueNode:
171
+ case $ node instanceof IntValueNode:
172
+ case $ node instanceof NameNode:
169
173
return $ node ->value ;
170
174
171
175
case $ node instanceof FieldDefinitionNode:
@@ -219,9 +223,6 @@ protected function p(?Node $node, bool $isDescription = false): string
219
223
' '
220
224
);
221
225
222
- case $ node instanceof FloatValueNode:
223
- return $ node ->value ;
224
-
225
226
case $ node instanceof FragmentDefinitionNode:
226
227
// Note: fragment variable definitions are experimental and may be changed or removed in the future.
227
228
return 'fragment ' . $ this ->p ($ node ->name )
@@ -310,18 +311,12 @@ protected function p(?Node $node, bool $isDescription = false): string
310
311
' '
311
312
);
312
313
313
- case $ node instanceof IntValueNode:
314
- return $ node ->value ;
315
-
316
314
case $ node instanceof ListTypeNode:
317
315
return '[ ' . $ this ->p ($ node ->type ) . '] ' ;
318
316
319
317
case $ node instanceof ListValueNode:
320
318
return '[ ' . $ this ->printList ($ node ->values , ', ' ) . '] ' ;
321
319
322
- case $ node instanceof NameNode:
323
- return $ node ->value ;
324
-
325
320
case $ node instanceof NamedTypeNode:
326
321
return $ this ->p ($ node ->name );
327
322
@@ -331,9 +326,6 @@ protected function p(?Node $node, bool $isDescription = false): string
331
326
case $ node instanceof NullValueNode:
332
327
return 'null ' ;
333
328
334
- case $ node instanceof ObjectFieldNode:
335
- return $ this ->p ($ node ->name ) . ': ' . $ this ->p ($ node ->value );
336
-
337
329
case $ node instanceof ObjectTypeDefinitionNode:
338
330
return $ this ->addDescription ($ node ->description , $ this ->join (
339
331
[
@@ -511,7 +503,7 @@ protected function printListBlock(NodeList $list): string
511
503
/** @throws \JsonException */
512
504
protected function addDescription (?StringValueNode $ description , string $ body ): string
513
505
{
514
- return $ this ->join ([$ this ->p ($ description, true ), $ body ], "\n" );
506
+ return $ this ->join ([$ this ->p ($ description ), $ body ], "\n" );
515
507
}
516
508
517
509
/**
0 commit comments