Skip to main content
Version: v10.0.0

GraphqlSubscriptionError

Error of a GraphQL subscription, reported to the socket.onError callbacks and to the onEnd of its listeners. The server ended the subscription with the error message - its validation or its source failed. errors holds what it sent.

Errors of a single event do not end the subscription and come with the event in extra.errors .


Import
import { GraphqlSubscriptionError } from "@hyper-fetch/graphql"

Parameters​

class GraphqlSubscriptionError {
constructor(__namedParameters: GraphqlSubscriptionErrorOptionsType) {};
topic: string;
payload: unknown;
errors: GraphQLFormattedError[];
}
Parameters
NameTypeDescription
__namedParameters
GraphqlSubscriptionErrorOptionsType

Properties​

errors​

Errors sent by the server with the error message

Type
GraphQLFormattedError[]

payload​

Variables of the failed subscription

Type
unknown

topic​

Topic of the failed subscription

Type
string

Usage​

socket.onError(({ error }) => {
if (error instanceof GraphqlSubscriptionError && error.errors[0].extensions?.code === "UNAUTHENTICATED") {
logout();
}
});