@apollo-link-debug/handle-request
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@apollo-link-debug/handle-request

Debugs the operation name and variables used for a GraphQL request via apollo.

Installation

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

Usage

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

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

const query = client.query({
  query: gql`query MyOperationName { ... }`,
  variables: {
    variableName: 'variableValue',
  },
});

Example output:

MyOperationName {
  "variableName": "variableValue"
}

Options

onRequest: ({ operation }) => void

A callback which occurs on every GraphQL request as the request is made. The default is to log the operation name and the variables (as JSON) used for the query.

Readme

Keywords

none

Package Sidebar

Install

npm i @apollo-link-debug/handle-request

Weekly Downloads

27

Version

0.0.5

License

MIT

Unpacked Size

3.77 kB

Total Files

8

Last publish

Collaborators

  • bashaus