Skip to content

Restore GraphQL caching after query failures - #201

Merged
timkelty merged 1 commit into
3.xfrom
timkelty/restore-gql-caching-on-error
Aug 28, 2026
Merged

Restore GraphQL caching after query failures#201
timkelty merged 1 commit into
3.xfrom
timkelty/restore-gql-caching-on-error

Conversation

@timkelty

Copy link
Copy Markdown
Contributor

An exception during GraphQL execution can skip the normal cleanup, leaving GraphQL result caching disabled for the rest of the request.

Ensure the request restores its original GraphQL caching setting even when execution fails.

Follow-up to #200 and #200 (comment).

Copilot AI lite review requested due to automatic review settings August 28, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures Craft Cloud’s StaticCache component restores the original enableGraphqlCaching setting even if GraphQL execution fails and the normal afterExecute cleanup doesn’t run, preventing GraphQL result caching from remaining disabled for the rest of the request.

Changes:

  • Restore enableGraphqlCaching and clear the internal $graphqlCachingStack during Response::EVENT_AFTER_PREPARE when a stack leak is detected.
  • Extend the unit test to simulate a failure path and assert GraphQL caching is restored and the stack is emptied.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/StaticCache.php Restores the original GraphQL caching config and clears the stack in handleAfterPrepareWebResponse() to guarantee cleanup even when query execution doesn’t reach the normal unwind path.
tests/unit/StaticCacheTest.php Adds coverage for the failure/cleanup scenario by forcing a non-OK response and asserting config restoration + stack reset.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@timkelty
timkelty marked this pull request as ready for review August 28, 2026 16:53
@timkelty
timkelty merged commit 3c29059 into 3.x Aug 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants