Skip to content

Unable to find Prisma Client in GraphQL context. Please provide it under the context.prisma key. #111

Answered by MichalLytek
omar-dulaimi asked this question in Q&A
Discussion options

You must be logged in to vote

Parameter decorator is not a right solution. It will connect and disconnect for every field resolver, meaning prisma batching won't work. And will be slow as turle 😅

Instead you should initialize prisma client in the context helper, so single graphql request which is handled by separate lambda will use single Prisma Client instance.

However you may need to dig in into Apollo Server docs to find a way to use hooks and plugins in order to disconnect from prisma, as TypeGraphQL is not responsible for the whole GraphQL execution pipeline, it only creates resolver handlers for GraphQL Schema.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@omar-dulaimi
Comment options

@omar-dulaimi
Comment options

@MichalLytek
Comment options

@omar-dulaimi
Comment options

Answer selected by omar-dulaimi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants