Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/drash/src/services/graphql/graphql.ts>GraphQL.subscribe

A microframework for Deno's HTTP server with zero third-party dependencies
Go to Latest
function GraphQL.subscribe
import { GraphQL } from "https://deno.land/x/drash@v2.8.1/src/services/graphql/graphql.ts";
const { subscribe } = GraphQL;

Implements the "Subscribe" algorithm described in the GraphQL specification.

Returns a Promise which resolves to either an AsyncIterator (if successful) or an ExecutionResult (client error). The promise will be rejected if a server error occurs.

If the client-provided arguments to this function do not result in a compliant subscription, a GraphQL Response (ExecutionResult) with descriptive errors and no data will be returned.

If the the source stream could not be created due to faulty subscription resolver logic or underlying systems, the promise will resolve to a single ExecutionResult containing errors and no data.

If the operation succeeded, the promise resolves to an AsyncIterator, which yields a stream of ExecutionResults representing the response stream.

Accepts either an object with named arguments, or individual arguments.

Returns

Promise<AsyncIterableIterator<ExecutionResult> | ExecutionResult>

Parameters

document: DocumentNode
optional
rootValue: any
optional
contextValue: any
optional
variableValues: Maybe<{ [key: string]: any; }>
optional
operationName: Maybe<string>
optional
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>
optional
subscribeFieldResolver: Maybe<GraphQLFieldResolver<any, any>>

Returns

Promise<AsyncIterableIterator<ExecutionResult> | ExecutionResult>