apollo-server/packages/apollo-server-micro
2017-08-09 17:30:13 +02:00
..
src Rename packages from graphql-server- to apollo-server- (#465) 2017-07-17 16:29:40 -07:00
.npmignore Rename packages from graphql-server- to apollo-server- (#465) 2017-07-17 16:29:40 -07:00
package.json Update dependencies 2017-08-09 17:30:13 +02:00
README.md Rename packages from graphql-server- to apollo-server- (#465) 2017-07-17 16:29:40 -07:00
tsconfig.json Rename packages from graphql-server- to apollo-server- (#465) 2017-07-17 16:29:40 -07:00

graphql-server-micro

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

Example

import { microGraphiql, microGraphql } from "graphql-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);