Hi - I'm using some various packages to try and get a graphql server up and running: type-graphql to generate my schema, and prisma to connect to my database. Everything is working fine but it seems express doesn't have access to the prisma client. Do you know what i am doing wrong?
Error: Unable to find Prisma Client in GraphQL context. Please provide it under the context[\"prisma\"] key
import express from "express";
import "reflect-metadata";
import { PrismaClient } from "@prisma/client";
import { resolvers } from "@generated/type-graphql";
import { buildSchema } from "type-graphql";
import { graphqlHTTP } from "express-graphql";
(async () => {
const prisma = new PrismaClient();
const schema = await buildSchema({
resolvers,
validate: false,
});
const app = express();
app.use(
"/graphql",
graphqlHTTP({
schema,
context: () => ({ prisma }),
graphiql: true,
})
);
app.listen(3000, () => {
console.log(`Example app listening on port 3000`);
});
})();
Hi - I'm using some various packages to try and get a graphql server up and running: type-graphql to generate my schema, and prisma to connect to my database. Everything is working fine but it seems express doesn't have access to the prisma client. Do you know what i am doing wrong?
Error:
Unable to find Prisma Client in GraphQL context. Please provide it under the context[\"prisma\"] key