Skip to main content
Module

x/graphql_http/mod.ts>createHandler

GraphQL client and handler compliant with GraphQL over HTTP specification
Latest
function createHandler
import { createHandler } from "https://deno.land/x/graphql_http@1.0.0-beta.20/mod.ts";

Create HTTP handler what handle GraphQL-over-HTTP request.

Examples

Example 1

import { createHandler } from "https://deno.land/x/graphql_http@$VERSION/mod.ts";
import { buildSchema } from "https://esm.sh/graphql@$VERSION";

const schema = buildSchema(`type Query { hello: String! }`);
const handler = createHandler(schema, {
  rootValue: {
    hello: "world",
  },
});
const req = new Request("<ENDPOINT>");
const res = await handler(req);

Parameters

schema: GraphQLSchema
optional
options: HandlerOptions

Returns

HttpHandler