Documentation
Modules
handler

Module: handler

Interfaces

Other

isExecutionResult

isExecutionResult(val): val is ExecutionResult<Record<string, unknown>, Record<string, unknown>>

Parameters

NameType
valunknown

Returns

val is ExecutionResult<Record<string, unknown>, Record<string, unknown>>

Defined in

src/handler.ts:1106

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

NameType
RequestRawunknown
RequestContextunknown

Type declaration

▸ (req): Promise<Response>

Parameters
NameType
reqRequest<RequestRaw, RequestContext>
Returns

Promise<Response>

Defined in

src/handler.ts:341


OperationArgs

Ƭ OperationArgs<Context>: ExecutionArgs & { contextValue: Context }

Type parameters

NameType
Contextextends OperationContext = undefined

Defined in

src/handler.ts:137


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

src/handler.ts:127


OperationResult

Ƭ OperationResult: Promise<AsyncGenerator<ExecutionResult | ExecutionPatchResult> | AsyncIterable<ExecutionResult | ExecutionPatchResult> | ExecutionResult> | AsyncGenerator<ExecutionResult | ExecutionPatchResult> | AsyncIterable<ExecutionResult | ExecutionPatchResult> | ExecutionResult

Defined in

src/handler.ts:141


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:115


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:95


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:81


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

NameType
RequestRawunknown
RequestContextunknown
Contextextends OperationContext = undefined

Parameters

NameType
optionsHandlerOptions<RequestRaw, RequestContext, Context>

Returns

Handler<RequestRaw, RequestContext>

Defined in

src/handler.ts:353