This repository was archived by the owner on Oct 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
tests/integration/GraphQL Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,14 @@ public function buildResponse(ResponseInterface $response)
4545 public function httpRequest ()
4646 {
4747 $ body = [
48- 'query ' => $ this ->query ,
49- 'variables ' => $ this ->variables ,
50- 'operationName ' => $ this ->operationName
48+ 'query ' => $ this ->query
5149 ];
50+ if (count ($ this ->variables ) > 0 ) {
51+ $ body ['variables ' ] = $ this ->variables ;
52+ }
53+ if (!is_null ($ this ->operationName )) {
54+ $ body ['operationName ' ] = $ this ->operationName ;
55+ }
5256 return new JsonRequest (HttpMethod::POST , $ this ->getPath (), $ body );
5357 }
5458
Original file line number Diff line number Diff line change @@ -76,4 +76,22 @@ public function testGraphQLEndpoint()
7676 $ result ['masterData ' ]['staged ' ]['name ' ]
7777 );
7878 }
79+
80+ public function testWithoutVariables ()
81+ {
82+ $ request = GraphQLQueryRequest::of ();
83+
84+ $ query = <<<GRAPHQL
85+ query Sphere {
86+ products {
87+ count
88+ }
89+ }
90+ GRAPHQL ;
91+
92+ $ request ->query ($ query );
93+
94+ $ response = $ request ->executeWithClient ($ this ->getClient ());
95+ $ this ->assertFalse ($ response ->isError ());
96+ }
7997}
You can’t perform that action at this time.
0 commit comments