apollo-server/packages/graphql-server-micro
Jonas Helfer 693991bdac v0.9.0
2017-06-22 13:36:12 -07:00
..
src Merge remote-tracking branch 'upstream/master' into graphiql-function 2017-06-16 11:00:42 -04:00
.npmignore Zeit micro support (#347) 2017-04-08 14:17:49 -07:00
package.json v0.9.0 2017-06-22 13:36:12 -07:00
README.md Add routing to micro tests 2017-06-15 21:10:16 -07:00
tsconfig.json Zeit micro support (#347) 2017-04-08 14:17:49 -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);