@@ -65,6 +65,7 @@ public function listen()
6565 {
6666 // obtain query and variables
6767 $ variables = $ this ->getVariables ();
68+ $ operationName = $ this ->getOperationName ();
6869 $ query = $ this ->getQuery ();
6970
7071 if ($ query === null ) {
@@ -103,7 +104,7 @@ public function listen()
103104
104105
105106 // execute query
106- $ result = $ this ->executor ->execute ($ this ->schema , $ this ->parser ->getParsedDocument (), null , null , $ variables );
107+ $ result = $ this ->executor ->execute ($ this ->schema , $ this ->parser ->getParsedDocument (), null , null , $ variables, $ operationName );
107108 $ this ->returnData ($ result );
108109
109110 } catch (Error $ error ) {
@@ -151,6 +152,25 @@ private function getQuery(): ?string
151152 }
152153 }
153154
155+ /**
156+ * Returns the operation name string from the raw post data.
157+ *
158+ * @return string|null
159+ */
160+ private function getOperationName (): ?string
161+ {
162+ // check if query is sent as raw http body in request as "application/json" or via post fields as "multipart/form-data"
163+ $ headers = apache_request_headers ();
164+ if (array_key_exists ("Content-Type " , $ headers ) and $ headers ["Content-Type " ] === "application/json " ) {
165+ // raw json string in http body
166+ $ phpInput = json_decode (file_get_contents ("php://input " ), true );
167+ return $ phpInput ["operationName " ] ?? null ;
168+ } else {
169+ // query sent via post field
170+ return $ _POST ["operationName " ] ?? null ;
171+ }
172+ }
173+
154174 /**
155175 * Returns the variables, sent by raw post data.
156176 *
0 commit comments