Created
January 3, 2018 03:44
-
-
Save xuxucode/1ea55ba024eeb5b1bf4e6734f4dc9ce8 to your computer and use it in GitHub Desktop.
Prevent caching if there is an error occurs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/GraphQL/Execution/QueryProcessor.php b/src/GraphQL/Execution/QueryProcessor.php | |
index 941b664..a2a7f27 100644 | |
--- a/src/GraphQL/Execution/QueryProcessor.php | |
+++ b/src/GraphQL/Execution/QueryProcessor.php | |
@@ -100,9 +100,9 @@ class QueryProcessor { | |
$metadata->addCacheableDependency($container->get('metadata')); | |
} | |
- // Prevent caching if this is a mutation query. | |
+ // Prevent caching if this is a mutation query or an error occurs. | |
$request = $context->getRequest(); | |
- if (!empty($request) && $request->hasMutations()) { | |
+ if (!empty($request) && $request->hasMutations() || $context->hasErrors()) { | |
$metadata->setCacheMaxAge(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment