@@ -27,22 +27,28 @@ trait HttpRequestTrait {
2727 * The server instance.
2828 * @param array $variables
2929 * Query variables.
30- * @param array|null $extensions
30+ * @param array $extensions
3131 * The query extensions.
3232 * @param bool $persisted
3333 * Flag if the query is actually the identifier of a persisted query.
3434 * @param string $method
3535 * Method, GET or POST.
36+ * @param string $operationName
37+ * Optional operation name if $query contains multiple operations.
3638 *
3739 * @return \Symfony\Component\HttpFoundation\Response
3840 * The http response object.
3941 */
40- protected function query ($ query , $ server = NULL , array $ variables = [], array $ extensions = NULL , $ persisted = FALSE , string $ method = Request::METHOD_GET ) {
42+ protected function query (
43+ string $ query ,
44+ ?Server $ server = NULL ,
45+ array $ variables = [],
46+ array $ extensions = [],
47+ bool $ persisted = FALSE ,
48+ string $ method = Request::METHOD_GET ,
49+ string $ operationName = ''
50+ ) {
4151 $ server = $ server ?: $ this ->server ;
42- if (!($ server instanceof Server)) {
43- throw new \LogicException ('Invalid server. ' );
44- }
45-
4652 $ endpoint = $ this ->server ->get ('endpoint ' );
4753 $ extensions = !empty ($ extensions ) ? ['extensions ' => $ extensions ] : [];
4854 // If the persisted flag is true, then instead of sending the full query to
@@ -52,6 +58,9 @@ protected function query($query, $server = NULL, array $variables = [], array $e
5258 $ query_key => $ query ,
5359 'variables ' => $ variables ,
5460 ] + $ extensions ;
61+ if ($ operationName ) {
62+ $ data ['operationName ' ] = $ operationName ;
63+ }
5564 if ($ method === Request::METHOD_GET ) {
5665 $ request = Request::create ($ endpoint , $ method , $ data );
5766 }
0 commit comments