Skip to content

Instantly share code, notes, and snippets.

@xuxucode
Created January 3, 2018 03:44
Show Gist options
  • Select an option

  • Save xuxucode/1ea55ba024eeb5b1bf4e6734f4dc9ce8 to your computer and use it in GitHub Desktop.

Select an option

Save xuxucode/1ea55ba024eeb5b1bf4e6734f4dc9ce8 to your computer and use it in GitHub Desktop.

Revisions

  1. xuxucode created this gist Jan 3, 2018.
    15 changes: 15 additions & 0 deletions graphql_cache_no_errors.patch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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);
    }