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
Server
Handler
Ƭ Handler<RequestRaw
, RequestContext
>: (req
: Request
<RequestRaw
, RequestContext
>) => 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.
Type parameters
Name | Type |
---|---|
RequestRaw | unknown |
RequestContext | unknown |
Type declaration
▸ (req
): Promise
<Response
>
Parameters
Name | Type |
---|---|
req | Request <RequestRaw , RequestContext > |
Returns
Promise
<Response
>
Defined in
OperationArgs
Ƭ OperationArgs<Context
>: ExecutionArgs
& { contextValue
: Context
}
Type parameters
Name | Type |
---|---|
Context | extends OperationContext = undefined |
Defined in
OperationContext
Ƭ OperationContext: Record
<PropertyKey
, unknown
> | symbol
| number
| string
| boolean
| undefined
| null
A concrete GraphQL execution context value type.
Mainly used because TypeScript collapses 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
OperationResult
Ƭ OperationResult: Promise
<AsyncGenerator
<ExecutionResult
| ExecutionPatchResult
> | AsyncIterable
<ExecutionResult
| ExecutionPatchResult
> | ExecutionResult
> | AsyncGenerator
<ExecutionResult
| ExecutionPatchResult
> | AsyncIterable
<ExecutionResult
| ExecutionPatchResult
> | ExecutionResult
Defined in
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
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
ResponseHeaders
Ƭ ResponseHeaders: { accept?
: string
; allow?
: string
; content-type?
: string
} & Record
<string
, string
>
The response headers that get returned from graphql-sse.
Defined in
createHandler
▸ createHandler<RequestRaw
, RequestContext
, Context
>(options
): Handler
<RequestRaw
, RequestContext
>
Makes a Protocol compliant 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
>