apollo-link-performance
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

apollo-link-performance

Easily tap into Apollo Client requests and log those in your performance tracking tool of choice.

Install

Via npm

npm install apollo-link-performance

Via Yarn

yarn add apollo-link-performance

How to use

import { ApolloClient, from, HTTPLink } from '@apollo/client'
import { performanceLink } from 'apollo-link-performance'
import analytics from '../libs/analytics'

const httpLink = new HttpLink({
  uri: https://mygraphqlapi.com,
})

const client = new ApolloClient({
  link: from([
    performanceLink({
      onRequestComplete: ({ data, dataSize, duration, operation }) => {
        analytics.track(`GraphQL Request - Performance`, {
          dataSize,
          duration,
          operationName: operation.operationName,
          operationType: operation.query.definitions[0].operation,
        })
      }
    })
    httpLink,
  ])
})

License

MIT © Pregraph

Readme

Keywords

none

Package Sidebar

Install

npm i apollo-link-performance

Weekly Downloads

82

Version

0.2.0

License

MIT

Unpacked Size

506 kB

Total Files

11

Last publish

Collaborators

  • ryanhefner