API
.compile(schema, queries, mutations, [middleware])
Micrograph's main export is compile
. compile
transforms:
- A
cohere
schema - A queries mapping
- A mutations mapping
- Middleware
into a GraphQLSchema
that can be plugged into your favorite GraphQL server (express-graphql, graphql-server, et al).
// compiled.js
import { compile } from 'micrograph';
import schema from './schema';
import queries from './queries';
import mutations from './mutations';
import middleware from './middleware';
export default compile(schema, queries, mutations, middleware);
Then somewhere in your application:
import express from 'express';
import graphqlHTTP from 'express-graphql';
import schema from './compiled';
const app = express();
app.use('/graphql', graphqlHTTP({ schema });
app.listen(4000);