-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(use): Deprecate
node
adapter in favor of http
and http2
ad…
…apters
- Loading branch information
Showing
10 changed files
with
431 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
[graphql-http](../README.md) / use/http | ||
|
||
# Module: use/http | ||
|
||
## Table of contents | ||
|
||
### Type Aliases | ||
|
||
- [HandlerOptions](use_http.md#handleroptions) | ||
|
||
### Functions | ||
|
||
- [createHandler](use_http.md#createhandler) | ||
|
||
## Server/http | ||
|
||
### HandlerOptions | ||
|
||
Ƭ **HandlerOptions**<`Context`\>: [`HandlerOptions`](../interfaces/handler.HandlerOptions.md)<`IncomingMessage`, `undefined`, `Context`\> | ||
|
||
Handler options when using the http adapter. | ||
|
||
#### Type parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `Context` | extends [`OperationContext`](handler.md#operationcontext) = `undefined` | | ||
|
||
___ | ||
|
||
### createHandler | ||
|
||
▸ **createHandler**<`Context`\>(`options`): (`req`: `IncomingMessage`, `res`: `ServerResponse`) => `Promise`<`void`\> | ||
|
||
Create a GraphQL over HTTP Protocol compliant request handler for | ||
the Node environment http module. | ||
|
||
```js | ||
import http from 'http'; | ||
import { createHandler } from 'graphql-http/lib/use/http'; | ||
import { schema } from './my-graphql-step'; | ||
|
||
const server = http.createServer(createHandler({ schema })); | ||
|
||
server.listen(4000); | ||
console.log('Listening to port 4000'); | ||
``` | ||
|
||
#### Type parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `Context` | extends [`OperationContext`](handler.md#operationcontext) = `undefined` | | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `options` | [`HandlerOptions`](use_http.md#handleroptions)<`Context`\> | | ||
|
||
#### Returns | ||
|
||
`fn` | ||
|
||
▸ (`req`, `res`): `Promise`<`void`\> | ||
|
||
##### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `req` | `IncomingMessage` | | ||
| `res` | `ServerResponse` | | ||
|
||
##### Returns | ||
|
||
`Promise`<`void`\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
[graphql-http](../README.md) / use/http2 | ||
|
||
# Module: use/http2 | ||
|
||
## Table of contents | ||
|
||
### Type Aliases | ||
|
||
- [HandlerOptions](use_http2.md#handleroptions) | ||
|
||
### Functions | ||
|
||
- [createHandler](use_http2.md#createhandler) | ||
|
||
## Server/http2 | ||
|
||
### HandlerOptions | ||
|
||
Ƭ **HandlerOptions**<`Context`\>: [`HandlerOptions`](../interfaces/handler.HandlerOptions.md)<`Http2ServerRequest`, `undefined`, `Context`\> | ||
|
||
Handler options when using the http adapter. | ||
|
||
#### Type parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `Context` | extends [`OperationContext`](handler.md#operationcontext) = `undefined` | | ||
|
||
___ | ||
|
||
### createHandler | ||
|
||
▸ **createHandler**<`Context`\>(`options`): (`req`: `Http2ServerRequest`, `res`: `Http2ServerResponse`) => `Promise`<`void`\> | ||
|
||
Create a GraphQL over HTTP Protocol compliant request handler for | ||
the Node environment http2 module. | ||
|
||
```shell | ||
$ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \ | ||
-keyout localhost-privkey.pem -out localhost-cert.pem | ||
``` | ||
|
||
```js | ||
import fs from 'fs'; | ||
import http2 from 'http2'; | ||
import { createHandler } from 'graphql-http/lib/use/http2'; | ||
import { schema } from './my-graphql-step'; | ||
|
||
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`](handler.md#operationcontext) = `undefined` | | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `options` | [`HandlerOptions`](use_http2.md#handleroptions)<`Context`\> | | ||
|
||
#### Returns | ||
|
||
`fn` | ||
|
||
▸ (`req`, `res`): `Promise`<`void`\> | ||
|
||
##### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `req` | `Http2ServerRequest` | | ||
| `res` | `Http2ServerResponse` | | ||
|
||
##### Returns | ||
|
||
`Promise`<`void`\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.