apollo-server/packages/graphql-server-koa
Mike Marcacci c22bb37996 Fixes broken graphiql endpoint
It looks like be01aee broke the graphiql endpoint by no longer returning the promise.
2017-06-30 20:09:50 -06:00
..
src Fixes broken graphiql endpoint 2017-06-30 20:09:50 -06:00
.npmignore chore(package): rename apollo-server to graphql-server 2016-10-18 09:36:07 +03:00
package.json v1.0.0 2017-06-29 00:05:56 -07:00
README.md Update README for koa 2017-06-29 00:05:56 -07:00
tsconfig.json Do not include types in koa, restify 2017-05-30 18:12:17 -07:00

graphql-server-koa

npm version Build Status Coverage Status Get on Slack

This is the Koa integration of GraphQL Server. GraphQL Server is a community-maintained open-source GraphQL server that works with all Node.js HTTP server frameworks: Express, Connect, Hapi, Koa and Restify. Read the docs.

Principles

GraphQL Server is built with the following principles in mind:

  • By the community, for the community: GraphQL Server's development is driven by the needs of developers
  • Simplicity: by keeping things simple, GraphQL Server is easier to use, easier to contribute to, and more secure
  • Performance: GraphQL Server is well-tested and production-ready - no modifications needed

Anyone is welcome to contribute to GraphQL Server, just read CONTRIBUTING.md, take a look at the roadmap and make your first PR!

Usage

import koa from 'koa'; // koa@2
import koaRouter from 'koa-router'; // koa-router@next
import koaBody from 'koa-bodyparser'; // koa-bodyparser@next
import { graphqlKoa } from 'graphql-server-koa';

const app = new koa();
const router = new koaRouter();
const PORT = 3000;

// koaBody is needed just for POST.
app.use(koaBody());

router.post('/graphql', graphqlKoa({ schema: myGraphQLSchema }));
router.get('/graphql', graphqlKoa({ schema: myGraphQLSchema }));

app.use(router.routes());
app.use(router.allowedMethods());
app.listen(PORT);