Socket
Socket
Sign inDemoInstall

@apollo-link-debug/handle-abort

Package Overview
Dependencies
37
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @apollo-link-debug/handle-abort

Debugs when a GraphQL request is aborted using an `AbortController`.


Version published
Maintainers
1
Created

Readme

Source

Debugs when a GraphQL request is aborted using an AbortController.

Because the same query can be used in multiple places with separate contexts, it is expected that the AbortController (signal) is provided when the query is run.

Installation

npm i @apollo-link-debug/handle-abort
# - or -
yarn add @apollo-link-debug/handle-abort

Usage

import { ApolloClient, ApolloLink, InMemoryCache } from '@apollo/client';
import { createAbortLink } from '@apollo-link-debug/handle-abort';

const client = new ApolloClient({
  uri: 'https://localhost:3000/',
  cache: new InMemoryCache(),
  link: ApolloLink.from([createAbortLink()]),
});

/* */

const abortController = new AbortController();

const query = client.query({
  query: gql`query MyOperationName { ... }`,
  context: {
    fetchOptions: {
      signal: abortController.signal,
    },
  },
});

abortController.abort();

Example output:

MyOperationName aborted

Options

onAbort: ({ operation }) => void

A callback which occurs when a GraphQL query is aborted. By default, this will console.log the operation name with the word aborted.

FAQs

Last updated on 14 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc