apollo-server/packages/apollo-server-micro
Martijn Walraven 9ba34306ed v1.3.0
2017-12-12 09:45:49 +01:00
..
src Rename packages from graphql-server- to apollo-server- (#465) 2017-07-17 16:29:40 -07:00
.npmignore include readme for npm packages 2017-10-23 15:13:31 -07:00
package.json v1.3.0 2017-12-12 09:45:49 +01:00
README.md Docs improvements (#692) 2017-12-11 23:11:11 -08:00
tsconfig.json Rename packages from graphql-server- to apollo-server- (#465) 2017-07-17 16:29:40 -07:00

title description
Micro Setting up Apollo Server with Micro

npm version Build Status Coverage Status Get on Slack

This is the Micro integration for the Apollo community GraphQL Server. Read the docs.

npm install apollo-server-micro

Example

import { microGraphiql, microGraphql } from 'apollo-server-micro';
import micro, { send } from 'micro';
import { get, post, router } from 'microrouter';
import schema from './schema';

const graphqlHandler = microGraphql({ schema });
const graphiqlHandler = microGraphiql({ endpointURL: '/graphql' });

const server = micro(
  router(
    get('/graphql', graphqlHandler),
    post('/graphql', graphqlHandler),
    get('/graphiql', graphiqlHandler),
    (req, res) => send(res, 404, 'not found')
  )
);

server.listen(3000);