File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -414,7 +414,7 @@ protected function p(?Node $node): string
414
414
return BlockString::print ($ node ->value );
415
415
}
416
416
417
- return json_encode ($ node ->value , JSON_THROW_ON_ERROR );
417
+ return json_encode ($ node ->value , JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES );
418
418
419
419
case $ node instanceof UnionTypeDefinitionNode:
420
420
$ typesStr = $ this ->printList ($ node ->types , ' | ' );
Original file line number Diff line number Diff line change @@ -291,4 +291,29 @@ public function testPrintPrimitives(): void
291
291
self ::assertASTMatches ('3 ' , AST ::astFromValue (3 , Type::int ()));
292
292
self ::assertASTMatches ('3.14 ' , AST ::astFromValue (3.14 , Type::float ()));
293
293
}
294
+
295
+ public function testDoNotEscapeForwardSlash (): void
296
+ {
297
+ $ ast = Parser::parse (
298
+ <<<'GRAPHQL'
299
+ query {
300
+ search(query: "repo: webonyx/graphql-php") {
301
+ id
302
+ }
303
+ }
304
+ GRAPHQL
305
+ );
306
+
307
+ self ::assertSame (
308
+ <<<'GRAPHQL'
309
+ {
310
+ search(query: "repo: webonyx/graphql-php") {
311
+ id
312
+ }
313
+ }
314
+
315
+ GRAPHQL,
316
+ Printer::doPrint ($ ast ),
317
+ );
318
+ }
294
319
}
You can’t perform that action at this time.
0 commit comments