New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

apollo-link-performance

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link-performance

Easily log and report on the performance of your GraphQL queries.

0.2.0
latest
Version published
Weekly downloads
88
-16.19%
Maintainers
1
Weekly downloads
 
Created

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

FAQs

Package last updated on 15 Jul 2022

Did you know?

Socket

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