-
Did i understand correctly that i should not use prisma in context of Yoga Graphql?
const prisma = new PrismaClient({}); const builder = new SchemaBuilder<{
PrismaTypes: PrismaTypes;
}>({
plugins: [PrismaPlugin],
prisma: {
client: prisma,
const yoga = createYoga({
context: (ctx) => { prisma } Thx! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
That sounds right. It's not specifically including it in the context in yoga that's the issue, but if you want resolvers in Pothos to know about the Prisma client on the context object you need to provide a Context type when creating the builder. If the Prisma client is included in that Context type (which represents the context you provide when setting up yoga) that's what can cause issues for larger schemas. It's been a long time since I've tested this, and Prisma, typescript, and Pothos have all gone through a lot of changes since, so I am not entirely sure how big an impact this has today. |
Beta Was this translation helpful? Give feedback.
-
if i have to use it in cloudflare i am forced to use it in context? thx! |
Beta Was this translation helpful? Give feedback.
There aren't any real issues with using it in context, other than some users experienced slow auto-completes in their editors. You can add it to the context and see how it works. The issue would only come up if you also add the types to the Context type in your builder.
I'm not super familiar with cloudflair so I'm not sure how Prisma works there. I think you need a per request client, which is easiest to do through context, but that isn't a hard requirement.