@@ -183,7 +183,8 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi
183183 return $ adapter ->createFulfilled (new QueryResult (NULL , $ errors ));
184184 }
185185
186- $ document = $ params ->queryId ? $ this ->loadPersistedQuery ($ config , $ params ) : $ params ->query ;
186+ $ persisted = isset ($ params ->queryId );
187+ $ document = $ persisted ? $ this ->loadPersistedQuery ($ config , $ params ) : $ params ->query ;
187188 if (!$ document instanceof DocumentNode) {
188189 $ document = Parser::parse ($ document );
189190 }
@@ -199,10 +200,10 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi
199200
200201 // Only queries can be cached (mutations and subscriptions can't).
201202 if ($ type === 'query ' ) {
202- return $ this ->executeCacheableOperation ($ adapter , $ config , $ params , $ document );
203+ return $ this ->executeCacheableOperation ($ adapter , $ config , $ params , $ document, ! $ persisted );
203204 }
204205
205- return $ this ->executeUncachableOperation ($ adapter , $ config , $ params , $ document );
206+ return $ this ->executeUncachableOperation ($ adapter , $ config , $ params , $ document, ! $ persisted );
206207 }
207208 catch (CacheableRequestError $ exception ) {
208209 return $ adapter ->createFulfilled (
@@ -222,10 +223,11 @@ protected function executeOperation(PromiseAdapter $adapter, ServerConfig $confi
222223 * @param \GraphQL\Server\ServerConfig $config
223224 * @param \GraphQL\Server\OperationParams $params
224225 * @param \GraphQL\Language\AST\DocumentNode $document
226+ * @param bool $validate
225227 *
226228 * @return \GraphQL\Executor\Promise\Promise|mixed
227229 */
228- protected function executeCacheableOperation (PromiseAdapter $ adapter , ServerConfig $ config , OperationParams $ params , DocumentNode $ document ) {
230+ protected function executeCacheableOperation (PromiseAdapter $ adapter , ServerConfig $ config , OperationParams $ params , DocumentNode $ document, $ validate = TRUE ) {
229231 $ contextCacheId = 'ccid: ' . $ this ->cacheIdentifier ($ params , $ document );
230232 if (!$ config ->getDebug () && $ contextCache = $ this ->cacheBackend ->get ($ contextCacheId )) {
231233 $ contexts = $ contextCache ->data ?: [];
@@ -235,7 +237,7 @@ protected function executeCacheableOperation(PromiseAdapter $adapter, ServerConf
235237 }
236238 }
237239
238- $ result = $ this ->doExecuteOperation ($ adapter , $ config , $ params , $ document );
240+ $ result = $ this ->doExecuteOperation ($ adapter , $ config , $ params , $ document, $ validate );
239241 return $ result ->then (function (QueryResult $ result ) use ($ contextCacheId , $ params , $ document ) {
240242 // Write this query into the cache if it is cacheable.
241243 if ($ result ->getCacheMaxAge () !== 0 ) {
@@ -256,11 +258,12 @@ protected function executeCacheableOperation(PromiseAdapter $adapter, ServerConf
256258 * @param \GraphQL\Server\ServerConfig $config
257259 * @param \GraphQL\Server\OperationParams $params
258260 * @param \GraphQL\Language\AST\DocumentNode $document
261+ * @param bool $validate
259262 *
260263 * @return \GraphQL\Executor\Promise\Promise
261264 */
262- protected function executeUncachableOperation (PromiseAdapter $ adapter , ServerConfig $ config , OperationParams $ params , DocumentNode $ document ) {
263- $ result = $ this ->doExecuteOperation ($ adapter , $ config , $ params , $ document );
265+ protected function executeUncachableOperation (PromiseAdapter $ adapter , ServerConfig $ config , OperationParams $ params , DocumentNode $ document, $ validate = TRUE ) {
266+ $ result = $ this ->doExecuteOperation ($ adapter , $ config , $ params , $ document, $ validate );
264267 return $ result ->then (function (QueryResult $ result ) {
265268 // Mark the query result as uncacheable.
266269 $ result ->mergeCacheMaxAge (0 );
@@ -273,13 +276,14 @@ protected function executeUncachableOperation(PromiseAdapter $adapter, ServerCon
273276 * @param \GraphQL\Server\ServerConfig $config
274277 * @param \GraphQL\Server\OperationParams $params
275278 * @param \GraphQL\Language\AST\DocumentNode $document
279+ * @param bool $validate
276280 *
277281 * @return \GraphQL\Executor\Promise\Promise
278282 */
279- protected function doExecuteOperation (PromiseAdapter $ adapter , ServerConfig $ config , OperationParams $ params , DocumentNode $ document ) {
283+ protected function doExecuteOperation (PromiseAdapter $ adapter , ServerConfig $ config , OperationParams $ params , DocumentNode $ document, $ validate = TRUE ) {
280284 // If one of the validation rules found any problems, do not resolve the
281285 // query and bail out early instead.
282- if ($ errors = $ this ->validateOperation ($ config , $ params , $ document )) {
286+ if ($ validate && $ errors = $ this ->validateOperation ($ config , $ params , $ document )) {
283287 return $ adapter ->createFulfilled (new QueryResult (NULL , $ errors ));
284288 }
285289
0 commit comments