Skip to content

Latest commit

 

History

History
69 lines (42 loc) · 1.48 KB

use_koa.md

File metadata and controls

69 lines (42 loc) · 1.48 KB

graphql-http / use/koa

Module: use/koa

Table of contents

Interfaces

Type Aliases

Functions

Server/koa

HandlerOptions

Ƭ HandlerOptions<Context>: HandlerOptions<IncomingMessage, RequestContext, Context>

Handler options when using the koa adapter.

Type parameters

Name Type
Context extends OperationContext = undefined

createHandler

createHandler<Context>(options): Middleware

Create a GraphQL over HTTP spec compliant request handler for the Koa framework.

import Koa from 'koa'; // yarn add koa
import mount from 'koa-mount'; // yarn add koa-mount
import { createHandler } from 'graphql-http/lib/use/koa';
import { schema } from './my-graphql-schema';

const app = new Koa();
app.use(mount('/', createHandler({ schema })));

app.listen({ port: 4000 });
console.log('Listening to port 4000');

Type parameters

Name Type
Context extends OperationContext = undefined

Parameters

Name Type
options HandlerOptions<Context>

Returns

Middleware