Unable to start the server in next js 13.2.
import { ApolloServer } from '@apollo/server';
import { startServerAndCreateNextHandler } from '@as-integrations/next';
const resolvers = {
Query: {
hello: () => 'world',
},
};
const typeDefs = `#graphql
type Query {
hello: String
}
`;
const server = new ApolloServer({
resolvers,
typeDefs,
});
export async function GET(request: Request) {
return startServerAndCreateNextHandler(server);
}
I tried to integrate the graphql server in next js 13.2 app directory api route but it's not working for me.
Unless you have a different workflow requirement, you seem to be missing the default?
Replace export async function ...
to
export default startServerAndCreateNextHandler(server);
Here's the reference for sample integration on NextJS https://github.com/apollo-server-integrations/apollo-server-integration-next