Skip to content

Latest commit

 

History

History
92 lines (59 loc) · 1.98 KB

use_http2.md

File metadata and controls

92 lines (59 loc) · 1.98 KB

graphql-http / use/http2

Module: use/http2

Table of contents

Interfaces

Type Aliases

Functions

Server/http2

HandlerOptions

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

Handler options when using the http adapter.

Type parameters

Name Type
Context extends OperationContext = undefined

createHandler

createHandler<Context>(options): (req: Http2ServerRequest, res: Http2ServerResponse) => Promise<void>

Create a GraphQL over HTTP spec compliant request handler for the Node environment http2 module.

$ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \
 -keyout localhost-privkey.pem -out localhost-cert.pem
import fs from 'fs';
import http2 from 'http2';
import { createHandler } from 'graphql-http/lib/use/http2';
import { schema } from './my-graphql-schema';

const server = http2.createSecureServer(
  {
    key: fs.readFileSync('localhost-privkey.pem'),
    cert: fs.readFileSync('localhost-cert.pem'),
  },
  createHandler({ schema }),
);

server.listen(4000);
console.log('Listening to port 4000');

Type parameters

Name Type
Context extends OperationContext = undefined

Parameters

Name Type
options HandlerOptions<Context>

Returns

fn

▸ (req, res): Promise<void>

Parameters
Name Type
req Http2ServerRequest
res Http2ServerResponse
Returns

Promise<void>