|
16 | 16 | - [Handler](handler.md#handler)
|
17 | 17 | - [OperationArgs](handler.md#operationargs)
|
18 | 18 | - [OperationContext](handler.md#operationcontext)
|
| 19 | +- [ParseRequestParams](handler.md#parserequestparams) |
19 | 20 | - [RequestHeaders](handler.md#requestheaders)
|
20 | 21 | - [Response](handler.md#response)
|
21 | 22 | - [ResponseBody](handler.md#responsebody)
|
@@ -108,6 +109,48 @@ the `context` server option.
|
108 | 109 |
|
109 | 110 | ___
|
110 | 111 |
|
| 112 | +### ParseRequestParams |
| 113 | + |
| 114 | +Ƭ **ParseRequestParams**<`RequestRaw`, `RequestContext`\>: (`req`: [`Request`](../interfaces/handler.Request.md)<`RequestRaw`, `RequestContext`\>) => `Promise`<[`RequestParams`](../interfaces/common.RequestParams.md) \| [`Response`](handler.md#response) \| `void`\> \| [`RequestParams`](../interfaces/common.RequestParams.md) \| [`Response`](handler.md#response) \| `void` |
| 115 | + |
| 116 | +#### Type parameters |
| 117 | + |
| 118 | +| Name | Type | |
| 119 | +| :------ | :------ | |
| 120 | +| `RequestRaw` | `unknown` | |
| 121 | +| `RequestContext` | `unknown` | |
| 122 | + |
| 123 | +#### Type declaration |
| 124 | + |
| 125 | +▸ (`req`): `Promise`<[`RequestParams`](../interfaces/common.RequestParams.md) \| [`Response`](handler.md#response) \| `void`\> \| [`RequestParams`](../interfaces/common.RequestParams.md) \| [`Response`](handler.md#response) \| `void` |
| 126 | + |
| 127 | +The request parser for an incoming GraphQL request. It parses and validates the |
| 128 | +request itself, including the request method and the content-type of the body. |
| 129 | + |
| 130 | +In case you are extending the server to handle more request types, this is the |
| 131 | +perfect place to do so. |
| 132 | + |
| 133 | +If an error is thrown, it will be formatted using the provided [FormatError](handler.md#formaterror) |
| 134 | +and handled following the spec to be gracefully reported to the client. |
| 135 | + |
| 136 | +Throwing an instance of `Error` will _always_ have the client respond with a `400: Bad Request` |
| 137 | +and the error's message in the response body; however, if an instance of `GraphQLError` is thrown, |
| 138 | +it will be reported depending on the accepted content-type. |
| 139 | + |
| 140 | +If you return nothing, the default parser will be used instead. |
| 141 | + |
| 142 | +##### Parameters |
| 143 | + |
| 144 | +| Name | Type | |
| 145 | +| :------ | :------ | |
| 146 | +| `req` | [`Request`](../interfaces/handler.Request.md)<`RequestRaw`, `RequestContext`\> | |
| 147 | + |
| 148 | +##### Returns |
| 149 | + |
| 150 | +`Promise`<[`RequestParams`](../interfaces/common.RequestParams.md) \| [`Response`](handler.md#response) \| `void`\> \| [`RequestParams`](../interfaces/common.RequestParams.md) \| [`Response`](handler.md#response) \| `void` |
| 151 | + |
| 152 | +___ |
| 153 | + |
111 | 154 | ### RequestHeaders
|
112 | 155 |
|
113 | 156 | Ƭ **RequestHeaders**: { `[key: string]`: `string` \| `string`[] \| `undefined`; `set-cookie?`: `string` \| `string`[] } \| { `get`: (`key`: `string`) => `string` \| ``null`` }
|
|
0 commit comments