Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[auth] Add RequestCache.clearForContext and export RequestCache class #1189

Merged
merged 3 commits into from Apr 17, 2024

Conversation

awinograd
Copy link
Contributor

If the scope initializer loads data that may change during a request for example due to a new user session or permission change then we need a way to clear the cache such that the scope initializer can be re-executed based on the new context state.

@hayes this contribution is based on our discord discussion: https://discord.com/channels/625400653321076807/868135255616417834/1227683491492135092

To be honest, I didn't fully grasp your message I'd probably also update... in terms of what you wanted to update. I will note that I ended up adding a new static method instead of a clearCache() instance method you were proposing as it seemed easier than to manually reset/reinitialize each of the instances internal caches. That said, I'm happy to update this PR as much as needed to get it to your liking.

If the scope initializer loads data that may change during a request
for example due to a new user session or permission change then we need
a way to clear the cache such that the scope initializer can be
re-executed based on the new context state.
Copy link

vercel bot commented Apr 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pothos ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2024 2:06pm

Copy link

changeset-bot bot commented Apr 16, 2024

🦋 Changeset detected

Latest commit: ae62a17

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@pothos/plugin-scope-auth Minor
@pothos/plugin-prisma Patch
@pothos/core Patch
@pothos-examples/complex-app Patch
@pothos-examples/prisma-federation Patch
@pothos-examples/prisma-relay Patch
@pothos-examples/prisma-smart-subscriptions-apollo Patch
@pothos-examples/prisma-subscriptions Patch
@pothos-examples/prisma Patch
@pothos-examples/envelope-helix-fastify Patch
@pothos-examples/federation Patch
@pothos-examples/graphql-shield Patch
@pothos-examples/helix Patch
@pothos-examples/nextjs Patch
@pothos-examples/open-telemetry Patch
@pothos-examples/relay-windowed-pagination Patch
@pothos-examples/simple-classes Patch
@pothos-examples/simple-interfaces Patch
@pothos/website Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hayes
Copy link
Owner

hayes commented Apr 17, 2024

Pushed up some changes here awinograd#1 that adds the change to use createContextCache

hayes and others added 2 commits April 17, 2024 00:33
Add clear method to context caches and update scope-auth plugin to use createContextCache
Copy link
Owner

@hayes hayes left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

@hayes hayes merged commit 24d070f into hayes:main Apr 17, 2024
3 checks passed
@awinograd
Copy link
Contributor Author

Thank you for the guidance @hayes !

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.

None yet

2 participants