Module: handler
Interfaces
Other
isExecutionResult
▸ isExecutionResult(val
): val is ExecutionResult<Record<string, unknown>, Record<string, unknown>>
Parameters
Name | Type |
---|---|
val | unknown |
Returns
val is ExecutionResult<Record<string, unknown>, Record<string, unknown>>
Defined in
src/handler.ts:1107 (opens in a new tab)
Server
Handler
Ƭ Handler<RequestRaw
, RequestContext
>: (req
: Request
<RequestRaw
, RequestContext
>) => Promise
<Response
>
Type parameters
Name | Type |
---|---|
RequestRaw | unknown |
RequestContext | unknown |
Type declaration
▸ (req
): Promise
<Response
>
The ready-to-use handler. Simply plug it in your favourite fetch-enabled HTTP framework and enjoy.
Errors thrown from any of the provided options or callbacks (or even due to library misuse or potential bugs) will reject the handler's promise. They are considered internal errors and you should take care of them accordingly.
Parameters
Name | Type |
---|---|
req | Request <RequestRaw , RequestContext > |
Returns
Promise
<Response
>
Defined in
src/handler.ts:340 (opens in a new tab)
OperationArgs
Ƭ OperationArgs<Context
>: ExecutionArgs
& { contextValue
: Context
}
Type parameters
Name | Type |
---|---|
Context | extends OperationContext = undefined |
Defined in
src/handler.ts:136 (opens in a new tab)
OperationContext
Ƭ OperationContext: Record
<PropertyKey
, unknown
> | symbol
| number
| string
| boolean
| undefined
| null
A concrete GraphQL execution context value type.
Mainly used because TypeScript collapes unions
with any
or unknown
to any
or unknown
. So,
we use a custom type to allow definitions such as
the context
server option.
Defined in
src/handler.ts:126 (opens in a new tab)
OperationResult
Ƭ OperationResult: Promise
<AsyncGenerator
<ExecutionResult
| ExecutionPatchResult
> | AsyncIterable
<ExecutionResult
| ExecutionPatchResult
> | ExecutionResult
> | AsyncGenerator
<ExecutionResult
| ExecutionPatchResult
> | AsyncIterable
<ExecutionResult
| ExecutionPatchResult
> | ExecutionResult
Defined in
src/handler.ts:140 (opens in a new tab)
Response
Ƭ Response: readonly [body: ResponseBody | null, init: ResponseInit]
Server agnostic response returned from graphql-sse
containing the
body and init options needing to be coerced to the server implementation in use.
Defined in
src/handler.ts:114 (opens in a new tab)
ResponseBody
Ƭ ResponseBody: string
| AsyncGenerator
<string
, void
, undefined
>
Server agnostic response body returned from graphql-sse
needing
to be coerced to the server implementation in use.
When the body is a string, it is NOT a GraphQL response.
Defined in
src/handler.ts:94 (opens in a new tab)
ResponseHeaders
Ƭ ResponseHeaders: { accept?
: string
; allow?
: string
; content-type?
: string
} & Record
<string
, string
>
The response headers that get returned from graphql-sse.
Defined in
src/handler.ts:80 (opens in a new tab)
createHandler
▸ createHandler<RequestRaw
, RequestContext
, Context
>(options
): Handler
<RequestRaw
, RequestContext
>
Makes a Protocol complient HTTP GraphQL server handler. The handler can be used with your favourite server library.
Read more about the Protocol in the PROTOCOL documentation file.
Type parameters
Name | Type |
---|---|
RequestRaw | unknown |
RequestContext | unknown |
Context | extends OperationContext = undefined |
Parameters
Name | Type |
---|---|
options | HandlerOptions <RequestRaw , RequestContext , Context > |
Returns
Handler
<RequestRaw
, RequestContext
>