Next 15 - Prisma - GraphQL - 500 TypeError: module.require
Unanswered
Morelet’s Crocodile posted this in #help-forum
Morelet’s CrocodileOP
I'm at the beginning stages of an app and can't seem to get past this error. I'm using Supabase and there's not much complexity here yet. Below is my
Here is the file contents. Any thoughts? Neither Google or any gpt can help me resolve this.
app/api/graphql/route.js
file contents. I'm using Postman to make a simple GraphQL request. I'm receiving this error in the terminal.Unexpected error processing request: TypeError: module.require is not a function
POST /api/graphql 500 in 1038ms
Here is the file contents. Any thoughts? Neither Google or any gpt can help me resolve this.
import { ApolloServer } from "@apollo/server";
import { startServerAndCreateNextHandler } from "@as-integrations/next";
import prisma from "../../../lib/prisma";
const typeDefs = `
type User {
id: ID!
email: String!
role: String!
}
type ServiceRequest {
id: ID!
title: String!
description: String!
status: String!
createdAt: String!
updatedAt: String!
}
type Query {
users: [User]
serviceRequests: [ServiceRequest]
}
`;
const resolvers = {
Query: {
users: async () => {
try {
return await prisma.user.findMany();
} catch (error) {
throw new Error("Failed to fetch users");
}
},
serviceRequests: async () => {
try {
return await prisma.serviceRequest.findMany();
} catch (error) {
throw new Error("Failed to fetch service requests");
}
},
},
};
const server = new ApolloServer({ typeDefs, resolvers });
const handler = startServerAndCreateNextHandler(server);
export { handler as GET, handler as POST };
2 Replies
Morelet’s CrocodileOP
here's my package.json
{
"name": "request",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@apollo/server": "^4.11.2",
"@as-integrations/next": "^3.2.0",
"@prisma/client": "^6.0.1",
"graphql": "^16.9.0",
"graphql-tag": "^2.12.6",
"graphql-tools": "^9.0.7",
"next": "15.1.0",
"next-connect": "^1.0.0",
"prisma": "^6.0.1",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.1.0",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}
Morelet’s CrocodileOP
for anyone else running into this problem. you must remove turbopack from
https://github.com/apollo-server-integrations/apollo-server-integration-next/issues/232
npm run dev
commandhttps://github.com/apollo-server-integrations/apollo-server-integration-next/issues/232