apollo-server/packages/apollo-server-micro
Martijn Walraven a750507fd6 v1.1.0
2017-08-09 21:12:51 +02:00
..
src Rename packages from graphql-server- to apollo-server- (#465) 2017-07-17 16:29:40 -07:00
.npmignore Include src/ directory in published npm packages 2017-08-09 21:09:02 +02:00
package.json v1.1.0 2017-08-09 21:12:51 +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);