-
-
Save JaosnHsieh/80474d92c89e479253b4df038d887757 to your computer and use it in GitHub Desktop.
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
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, gql } from 'apollo-server-micro'; | |
const typeDefs = gql` | |
type Query { | |
sayHello: String | |
} | |
`; | |
const resolvers = { | |
Query: { | |
sayHello(parent, args, context) { | |
return 'Hello World!'; | |
} | |
} | |
}; | |
const apolloServer = new ApolloServer({ typeDefs, resolvers }); | |
export const config = { | |
api: { | |
bodyParser: false | |
} | |
}; | |
export default apolloServer.createHandler({ path: '/api/graphql' }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment