Created
September 3, 2021 17:57
-
-
Save crisu83/d89befb863cada678888c1160880a9f2 to your computer and use it in GitHub Desktop.
GraphQL API route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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