Skip to content

Typegraphql with NextJS 13 #375

Closed Answered by Jdelgad8
Jdelgad8 asked this question in Q&A
Discussion options

You must be logged in to vote

I solved it like this and it's working:
import "reflect-metadata";
import { ApolloServer } from "@apollo/server";
import { startServerAndCreateNextHandler } from "@as-integrations/next";
import { buildSchema } from "type-graphql";
import { NextRequest } from "next/server";
import { resolvers } from "../../../../prisma/generated/type-graphql";
import { PrismaClient } from "@prisma/client";

export async function GET(request: NextRequest) {
const schema = await buildSchema({
resolvers,
validate: false,
});

const server = new ApolloServer({
schema,

formatError: (error) => error,

});

const handler = startServerAndCreateNextHandler(server, {
context: async (req) => ({ req }),
});
return handle…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Jdelgad8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant