Skip to content

Instantly share code, notes, and snippets.

@crisu83
Created September 3, 2021 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crisu83/d89befb863cada678888c1160880a9f2 to your computer and use it in GitHub Desktop.
Save crisu83/d89befb863cada678888c1160880a9f2 to your computer and use it in GitHub Desktop.
GraphQL API route
import {ApolloServer} from 'apollo-server-micro';
import {NextApiRequest, NextApiResponse} from 'next';
import {resolvers} from '@/graphql/resolvers';
import typeDefs from '@/graphql/schema.graphql';
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
return new ApolloServer(
resolvers,
typeDefs,
}).createHandler({path: '/api/graphql'})(req, res);
};
export const config = {
api: {
bodyParser: false,
},
};
export default handler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment