UNPKG

apollo-link-timeout

Version:

Abort requests that take longer than a specified timeout period

19 lines (18 loc) 818 B
/// <reference types="zen-observable" /> import { ApolloLink, Observable, type Operation, type NextLink } from '@apollo/client/core'; /** * Aborts the request if the timeout expires before the response is received. */ export default class TimeoutLink extends ApolloLink { private timeout; private statusCode?; /** * Creates a new TimeoutLink instance. * Aborts the request if the timeout expires before the response is received. * * @param timeout - The timeout in milliseconds for the request. Default is 15000ms (15 seconds). * @param statusCode - The HTTP status code to return when a timeout occurs. Default is 408 (Request Timeout). */ constructor(timeout?: number, statusCode?: number); request(operation: Operation, forward: NextLink): Observable<unknown>; }