Created
October 14, 2017 00:24
-
-
Save govorov/37fb48ce70f4938b1c523bc1d7afecdc to your computer and use it in GitHub Desktop.
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 * as Router from 'koa-router'; | |
import * as koaBody from 'koa-bodyparser'; | |
import { | |
graphqlKoa, | |
graphiqlKoa, | |
} from 'apollo-server-koa'; | |
import { schema } from 'graphql/schema'; | |
export const routes = new Router(); | |
// API entrypoint | |
const apiEntrypointPath = '/graphql'; | |
const graphQlOpts = graphqlKoa({ | |
schema, | |
}); | |
routes.get(apiEntrypointPath, graphQlOpts); | |
routes.post(apiEntrypointPath, koaBody(), graphQlOpts); | |
// GraphiQL entrypoint | |
routes.get('/graphiql', graphiqlKoa({ endpointURL: apiEntrypointPath })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment