apollo-server/packages/apollo-server-micro/README.md

27 lines
761 B
Markdown
Raw Normal View History

# graphql-server-micro
This is the [Micro](https://github.com/zeit/micro) integration for the Apollo community GraphQL Server. [Read the docs.](http://dev.apollodata.com/tools/apollo-server/index.html)
2017-05-24 00:29:15 -06:00
## Example
```typescript
import { microGraphiql, microGraphql } from "graphql-server-micro";
import micro, { send } from "micro";
import { get, post, router } from "microrouter";
import schema from "./schema";
2017-06-05 15:58:10 -06:00
const graphqlHandler = microGraphql({ schema });
const graphiqlHandler = microGraphiql({ endpointURL: "/graphql" });
2017-05-24 00:29:15 -06:00
const server = micro(
router(
get("/graphql", graphqlHandler),
post("/graphql", graphqlHandler),
2017-06-05 15:58:10 -06:00
get("/graphiql", graphiqlHandler),
(req, res) => send(res, 404, "not found"),
2017-05-24 00:29:15 -06:00
),
);
server.listen(3000);
```