Skip to content

fix(response_cache): change plugin ordering to make sure we can customize caching behavior at the subgraph level#8652

Merged
bnjjj merged 5 commits intodevfrom
bnjjj/router_1539
Nov 26, 2025
Merged

fix(response_cache): change plugin ordering to make sure we can customize caching behavior at the subgraph level#8652
bnjjj merged 5 commits intodevfrom
bnjjj/router_1539

Conversation

@bnjjj
Copy link
Copy Markdown
Contributor

@bnjjj bnjjj commented Nov 21, 2025

With this change you'll now be able to customize cached response using rhai or coprocessors. It's also now possible to set a different private_id based on subgraph request (like headers for example).

Example of rhai script customizing the private_id:

fn subgraph_service(service, subgraph) {
    service.map_request(|request| {
        if "private_id" in request.headers {
            request.context["private_id"] = request.headers["private_id"];
        }
    });
}


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

…mize caching behavior at the subgraph level

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj bnjjj requested a review from a team November 21, 2025 09:36
@apollo-librarian
Copy link
Copy Markdown
Contributor

apollo-librarian bot commented Nov 21, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 1 changed, 0 removed
* graphos/routing/(latest)/performance/caching/response-caching/customization.mdx

Build ID: 21cd86fe8d4cf3fbc3b387d0
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/21cd86fe8d4cf3fbc3b387d0

@github-actions

This comment has been minimized.

@bnjjj bnjjj requested review from BrynCooke and carodewig November 21, 2025 09:37
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj bnjjj requested a review from a team as a code owner November 21, 2025 10:01
Copy link
Copy Markdown
Contributor

@carodewig carodewig left a comment

Choose a reason for hiding this comment

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

👍 it's intuitive that caching would be the last layer around a service, allowing you to customize things in how the cached item is determined.
I think it would be worth calling out this behavior in the response caching docs.

Would like another person to review, but this makes sense to me!

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj bnjjj requested a review from carodewig November 25, 2025 15:58
@bnjjj bnjjj enabled auto-merge (squash) November 26, 2025 10:03
@bnjjj bnjjj merged commit da2245d into dev Nov 26, 2025
15 checks passed
@bnjjj bnjjj deleted the bnjjj/router_1539 branch November 26, 2025 10:14
@abernix abernix mentioned this pull request Dec 12, 2025
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.

3 participants