@@ -92,14 +92,16 @@ public function testPersistedQueryNotFound(): void
9292
9393 public function testPersistedQueryFound (): void
9494 {
95+ $ hash = hash ('sha256 ' , trim ($ this ->queries ['examples ' ]));
96+
9597 // run query and persist
9698
9799 $ response = $ this ->call ('GET ' , '/graphql ' , [
98100 'query ' => trim ($ this ->queries ['examples ' ]),
99101 'extensions ' => [
100102 'persistedQuery ' => [
101103 'version ' => 1 ,
102- 'sha256Hash ' => hash ( ' sha256 ' , trim ( $ this -> queries [ ' examples ' ])) ,
104+ 'sha256Hash ' => $ hash ,
103105 ],
104106 ],
105107 ]);
@@ -111,13 +113,13 @@ public function testPersistedQueryFound(): void
111113 self ::assertArrayHasKey ('data ' , $ content );
112114 self ::assertEquals (['examples ' => $ this ->data ], $ content ['data ' ]);
113115
114- // run persisted query
116+ // run persisted query using POST
115117
116- $ response = $ this ->call ('GET ' , '/graphql ' , [
118+ $ response = $ this ->call ('POST ' , '/graphql ' , [
117119 'extensions ' => [
118120 'persistedQuery ' => [
119121 'version ' => 1 ,
120- 'sha256Hash ' => hash ( ' sha256 ' , trim ( $ this -> queries [ ' examples ' ])) ,
122+ 'sha256Hash ' => $ hash ,
121123 ],
122124 ],
123125 ]);
@@ -128,6 +130,17 @@ public function testPersistedQueryFound(): void
128130
129131 self ::assertArrayHasKey ('data ' , $ content );
130132 self ::assertEquals (['examples ' => $ this ->data ], $ content ['data ' ]);
133+
134+ // run persisted query using GET
135+
136+ $ response = $ this ->call ('GET ' , '/graphql?extensions={"persistedQuery":{"version":1,"sha256Hash":" ' . $ hash . '"}} ' );
137+
138+ self ::assertEquals (200 , $ response ->getStatusCode ());
139+
140+ $ content = $ response ->json ();
141+
142+ self ::assertArrayHasKey ('data ' , $ content );
143+ self ::assertEquals (['examples ' => $ this ->data ], $ content ['data ' ]);
131144 }
132145
133146 // This test demonstrates we don't actually check the 'version'
0 commit comments