//app/api/graphql/route.ts
import { startServerAndCreateNextHandler } from '@as-integrations/next';
import { ApolloServer } from '@apollo/server';
import { gql } from 'graphql-tag';
import { NextRequest } from 'next/server';
const resolvers = {
Query: {
hello: () => 'world',
},
};
const typeDefs = gql`
type Query {
hello: String
}
`;
const server = new ApolloServer({
resolvers,
typeDefs,
});
const handler = startServerAndCreateNextHandler<NextRequest>(server, {
context: async req => ({ req }),
});
export { handler as GET, handler as POST };
When I tried to visit http://localhost:3000/api/graphql I got this response
{
"errors": [
{
"message": "module.require is not a function",
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"stacktrace": [
"TypeError: module.require is not a function",
" at createHash (.next\\server\\chunks\\node_modules__pnpm_f22ca6._.js:5380:23)",
" at Object.html (.next\\server\\chunks\\node_modules__pnpm_7ff79c._.js:241:323)",
" at ApolloServer.executeHTTPGraphQLRequest (.next\\server\\chunks\\53229_@apollo_server_dist_157170._.js:6283:77)"
]
}
}
]
}
what am I doing wrong here?