GraphQL LogoGraphQL

graphql-http

The official graphql-http package provides a simple way to create a fully compliant GraphQL server. It has a handler for Node.js native http, together with handlers for well-known frameworks like Express, Fastify and Koa; as well as handlers for different runtimes like Deno and Bun.

Express#

import { createHandler } from "graphql-http/lib/use/express" // ES6
const { createHandler } = require("graphql-http/lib/use/express") // CommonJS

createHandler#

createHandler({
schema: GraphQLSchema,
rootValue?: ?any,
context?: ?any,
formatError?: ?Function,
validationRules?: ?Array<any>,
}): Handler

Constructs an Express handler based on a GraphQL schema.

See the tutorial for sample usage.

See the GitHub README for more extensive documentation, including how to use graphql-http with other server frameworks and runtimes.

Continue Reading →graphql