Hello, is there a way to access the context from t...
# orm-help
i
Hello, is there a way to access the context from the middleware?
r
Hey @Isidoro Ferreiro 👋 By middleware if you mean Prisma middleware, then no it’s not possible to access the GraphQL context there. If you just require the
PrismaClient
instance then directly use the one that you have passed in the context. Let me know if you have another use case for this 🙂
i
Hey @Ryan I wanted the middleware to add the user id (from the sub claim) as a filter to all of the queries, so I don't have to do so manually in all of them
r
Unfortunately that wouldn’t be possible as GraphQL context wouldn’t have access to Prisma’s middleware, which is why the
user_id
won’t be available there.
n
Hey @Isidoro Ferreiro 👋 check out graphql-middleware, maybe that's what you're looking for? 🙂
i
It’s okay, thanks @Ryan!
💯 1
Will take a look @nikolasburk
👌 1