Auth plugin values available in a resolver? #1380
Replies: 1 comment
-
It's not part of the documented public API, but you can technically do something like: import { RequestCache } from '@pothos/plugin-scope-auth'
const cache = RequestCache.fromContext(ctx)
const isAdmin = cache.get('admin')!.get(true) the request cache isn't meant to be used in apps, and doesn't have the simple APIs you are probably looking for. Auth scopes aren't really just things like What i'd do instead is extend your |
Beta Was this translation helpful? Give feedback.
-
I've got a builder set up using the AuthPlugin like this:
So two auth scopes exist in my app,
user
which would be any logged-in user, andadmin
which would be users that have a specific permission. In this scenario, is there any way to get the computed value ofauthScopes
in a resolver?ie:
I know technically
currentUser
exists in context so I can do the checks again, I'm just trying to reduce duplication on every query that is like the above - a query that is open to users and technically admins (as they pass the logged in user check) but we want to know generally if the user is also an adminBeta Was this translation helpful? Give feedback.
All reactions