@@ -281,18 +281,18 @@ public function executeOperation(OperationParams $params, GraphQLContext $contex
281281 */
282282 public function parse (string $ query , string $ hash ): DocumentNode
283283 {
284- $ cacheConfig = $ this ->configRepository ->get ('lighthouse.query_cache ' );
284+ $ queryCacheConfig = $ this ->configRepository ->get ('lighthouse.query_cache ' );
285285
286- if (! $ cacheConfig ['enable ' ]) {
286+ if (! $ queryCacheConfig ['enable ' ]) {
287287 return $ this ->parseQuery ($ query );
288288 }
289289
290290 $ cacheFactory = Container::getInstance ()->make (CacheFactory::class);
291- $ store = $ cacheFactory ->store ($ cacheConfig ['store ' ]);
291+ $ store = $ cacheFactory ->store ($ queryCacheConfig ['store ' ]);
292292
293293 return $ store ->remember (
294294 "lighthouse:query: {$ hash }" ,
295- $ cacheConfig ['ttl ' ],
295+ $ queryCacheConfig ['ttl ' ],
296296 fn (): DocumentNode => $ this ->parseQuery ($ query ),
297297 );
298298 }
@@ -319,17 +319,17 @@ public function toSerializableArray(ExecutionResult $result): array
319319 public function loadPersistedQuery (string $ sha256hash ): DocumentNode
320320 {
321321 $ lighthouseConfig = $ this ->configRepository ->get ('lighthouse ' );
322- $ cacheConfig = $ lighthouseConfig ['query_cache ' ] ?? null ;
322+ $ queryCacheConfig = $ lighthouseConfig ['query_cache ' ];
323323 if (
324- ! ( $ lighthouseConfig ['persisted_queries ' ] ?? false )
325- || ! ( $ cacheConfig ['enable ' ] ?? false )
324+ ! $ lighthouseConfig ['persisted_queries ' ]
325+ || ! $ queryCacheConfig ['enable ' ]
326326 ) {
327327 // https://github.com/apollographql/apollo-server/blob/37a5c862261806817a1d71852c4e1d9cdb59eab2/packages/apollo-server-errors/src/index.ts#L240-L248
328328 throw new Error ('PersistedQueryNotSupported ' , null , null , [], null , null , ['code ' => 'PERSISTED_QUERY_NOT_SUPPORTED ' ]);
329329 }
330330
331331 $ cacheFactory = Container::getInstance ()->make (CacheFactory::class);
332- $ store = $ cacheFactory ->store ($ cacheConfig ['store ' ]);
332+ $ store = $ cacheFactory ->store ($ queryCacheConfig ['store ' ]);
333333
334334 return $ store ->get ("lighthouse:query: {$ sha256hash }" )
335335 // https://github.com/apollographql/apollo-server/blob/37a5c862261806817a1d71852c4e1d9cdb59eab2/packages/apollo-server-errors/src/index.ts#L230-L239
@@ -407,17 +407,17 @@ protected function validateCacheableRules(
407407 return DocumentValidator::validate ($ schema , $ query , $ validationRules ); // @phpstan-ignore return.type (TODO remove ignore when requiring a newer version of webonyx/graphql-php)
408408 }
409409
410- $ cacheConfig = $ this ->configRepository ->get ('lighthouse.validation_cache ' );
410+ $ validationCacheConfig = $ this ->configRepository ->get ('lighthouse.validation_cache ' );
411411
412- if (! isset ( $ cacheConfig [ ' enable ' ]) || ! $ cacheConfig ['enable ' ]) {
412+ if (! $ validationCacheConfig ['enable ' ]) {
413413 return DocumentValidator::validate ($ schema , $ query , $ validationRules ); // @phpstan-ignore return.type (TODO remove ignore when requiring a newer version of webonyx/graphql-php)
414414 }
415415
416- $ cacheKey = "lighthouse:validation: {$ schemaHash }: {$ queryHash }" ;
417-
418416 $ cacheFactory = Container::getInstance ()->make (CacheFactory::class);
417+ $ store = $ cacheFactory ->store ($ validationCacheConfig ['store ' ]);
418+
419+ $ cacheKey = "lighthouse:validation: {$ schemaHash }: {$ queryHash }" ;
419420
420- $ store = $ cacheFactory ->store ($ cacheConfig ['store ' ]);
421421 $ cachedResult = $ store ->get ($ cacheKey );
422422 if ($ cachedResult !== null ) {
423423 return $ cachedResult ;
@@ -432,7 +432,7 @@ protected function validateCacheableRules(
432432 return $ result ; // @phpstan-ignore return.type (TODO remove ignore when requiring a newer version of webonyx/graphql-php)
433433 }
434434
435- $ store ->put ($ cacheKey , $ result , $ cacheConfig ['ttl ' ]);
435+ $ store ->put ($ cacheKey , $ result , $ validationCacheConfig ['ttl ' ]);
436436
437437 return $ result ;
438438 }
0 commit comments