Skip to content

feat: scope-aware caching with session_id callback#25

Merged
nogueira-raphael merged 1 commit intomainfrom
feat/scope-aware-session-id
Feb 16, 2026
Merged

feat: scope-aware caching with session_id callback#25
nogueira-raphael merged 1 commit intomainfrom
feat/scope-aware-session-id

Conversation

@nogueira-raphael
Copy link
Copy Markdown
Owner

Summary

  • Replace session_context_keys (CacheConfig field) with a session_id callback on the Ariadne adapter, following Apollo Server's scope-aware caching model
  • Implement dual cache lookup: private key first (per-user), then public key (shared), so PUBLIC queries are never needlessly cached per-user
  • PRIVATE responses without a session_id are skipped (not cached), with a warning logged
  • Simplify Strawberry extension to public-only caching (context=None) until scope calculation is added

Test plan

  • TestGetSessionId — callback returns value, returns None, no callback
  • TestDualLookup — private hit, public hit after private miss, both miss, no sid skips private
  • TestScopeAwareStore — PUBLIC stores with context=None, PRIVATE+sid stores with session context, PRIVATE without sid skips, not cacheable skips
  • TestScopeAwareCaching (integration) — private per-user isolation, public shared across users
  • Strawberry tests updated to assert context=None uniformly
  • All 233 tests passing, mypy clean, ruff clean on changed files

Replace session_context_keys with a session_id callback on the Ariadne
adapter. PUBLIC responses use a shared cache key while PRIVATE responses
are cached per-user via the session_id. PRIVATE responses without a
session_id are not cached. Strawberry reverts to public-only caching
until scope calculation is added.
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.74%. Comparing base (9898a62) to head (e284883).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
+ Coverage   88.10%   89.74%   +1.63%     
==========================================
  Files          33       33              
  Lines         925      926       +1     
  Branches      140      142       +2     
==========================================
+ Hits          815      831      +16     
+ Misses         87       71      -16     
- Partials       23       24       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nogueira-raphael nogueira-raphael merged commit 2109257 into main Feb 16, 2026
7 checks passed
@nogueira-raphael nogueira-raphael deleted the feat/scope-aware-session-id branch February 16, 2026 21:08
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.

1 participant