Created
July 8, 2019 20:42
-
-
Save mfellner/2119db3584023092d70118a8dabd146e 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 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
How would you use this in
getStaticProps
?