prisma-plugin: getting error when adding plugin to builder #420
Answered
by
hayes
nerdroid23
asked this question in
Q&A
-
Hello, I want to preface that I am a complete noob, I apologize if I am not doing something correctly. I am trying to use the prisma-plugin and i am getting an odd error and I have not yet figured out what it wrong. I am using nextjs and graphql-yoga. This is the error that I am getting // builder.ts
import SchemaBuilder from "@pothos/core";
import { prisma } from "../prisma/prisma";
import { PrismaPlugin } from "@pothos/plugin-prisma";
import type PrismaTypes from "@pothos/plugin-prisma/generated";
export const builder = new SchemaBuilder<{
PrismaTypes: PrismaTypes;
}>({
plugins: [PrismaPlugin],
prisma: {
client: prisma,
},
}); // prisma.ts
import { PrismaClient } from "@prisma/client";
declare global {
// allow global `var` declarations
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}
export const prisma =
global.prisma ||
new PrismaClient({
log: ["query"],
});
if (process.env.NODE_ENV !== "production") global.prisma = prisma; Any help would be greatly appreciated! 🙏🏾 |
Beta Was this translation helpful? Give feedback.
Answered by
hayes
Jun 13, 2022
Replies: 1 comment 1 reply
-
You want to use the default export of the plugin, not the named class export. Eg import PrismaPlugin instead of import { PrismaPlugin } |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
nerdroid23
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You want to use the default export of the plugin, not the named class export.
Eg import PrismaPlugin instead of import { PrismaPlugin }