Skip to content

Latest commit

 

History

History
97 lines (60 loc) · 3.26 KB

server.md

File metadata and controls

97 lines (60 loc) · 3.26 KB

graphql-ws / server

Module: server

Table of contents

Interfaces

Type Aliases

Functions

Server

GraphQLExecutionContextValue

Ƭ GraphQLExecutionContextValue: object | 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.


OperationResult

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


handleProtocols

handleProtocols(protocols): typeof GRAPHQL_TRANSPORT_WS_PROTOCOL | false

Helper utility for choosing the "graphql-transport-ws" subprotocol from a set of WebSocket subprotocols.

Accepts a set of already extracted WebSocket subprotocols or the raw Sec-WebSocket-Protocol header value. In either case, if the right protocol appears, it will be returned.

By specification, the server should not provide a value with Sec-WebSocket-Protocol if it does not agree with client's subprotocols. The client has a responsibility to handle the connection afterwards.

Parameters

Name Type
protocols string | string[] | Set<string>

Returns

typeof GRAPHQL_TRANSPORT_WS_PROTOCOL | false


makeServer

makeServer<P, E>(options): Server<E>

Makes a Protocol complient WebSocket GraphQL server. The server is actually an API which is to be used with your favourite WebSocket server library!

Read more about the Protocol in the PROTOCOL.md documentation file.

Type parameters

Name Type
P extends undefined | Record<string, unknown> = undefined | Record<string, unknown>
E unknown

Parameters

Name Type
options ServerOptions<P, E>

Returns

Server<E>