Martin Pinnau
05/13/2022, 1:05 PMyarn add @graphql-yoga/node. If I migrate to graphql-yoga v2 I get the error that nexus is needed, but this breaks nexus-plugin-prisma. Could someone please help me ? 😉
This is my index.ts:
require("dotenv").config();
import { PrismaClient } from "@prisma/client";
import * as path from "path";
import { nexusSchemaPrisma } from "nexus-plugin-prisma/schema";
import { makeSchema } from "@nexus/schema";
import { createServer } from "@graphql-yoga/node";
import { checkEnv } from "./src/utils";
import { getClaims } from "./src/auth";
import config from "./config";
import { Query, Mutation } from "./src/types";
checkEnv(config.requieredEnvs);
const schema = makeSchema({
types: [Query, Mutation],
plugins: [
nexusSchemaPrisma({
experimentalCRUD: true,
}),
],
outputs: {
schema: path.join(__dirname, "./src/generated/schema.graphql"),
typegen: path.join(__dirname, "./src/generated/nexus.ts"),
},
});
const serverOptions = {
port: process.env.MAIL_PORT || 4000,
};
const server = createServer({
schema,
context: async (req) => {
return {
...req,
PrismaClient,
claims: await getClaims(req),
options: serverOptions,
};
},
});
server.start();
console.log(`🚀 Server is running on <http://localhost>:${serverOptions.port}`);Nurul
05/25/2022, 12:42 PM