apollo-link-firebase-performance-monitoring

Firebase Performance Monitoring for Apollo GraphQL Client using Apollo Link

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
apollo-link-firebase-performance-monitoring
401.0.93 years ago5 years agoMinified + gzip package size for apollo-link-firebase-performance-monitoring in KB

Readme

apollo-link-firebase-performance-monitoring
Firebase Performance Monitoring for Apollo GraphQL Client using Apollo Link
!versionversion-badgepackage !downloadsdownloads-badgenpmtrends !MIT Licenselicense-badgeLICENSE !Watch on GitHubgithub-watch-badgegithub-watch !Star on GitHubgithub-star-badgegithub-star

Installing / Getting Started

npm install apollo-link-firebase-performance-monitoring

Prerequisites

  • Apollo Link: ^1.2.14
  • Firebase: ^6.6.1 || ^7.2.1 || ^7.15.5

// Firebase App (the core Firebase SDK) is always required and must be listed first
import * as firebase from "firebase/app";

// Add the Performance Monitoring library
import "firebase/performance";

// Add import for Apollo Link
import { from } from 'apollo-link';

// Add the import for this library
import createFPMLink from 'apollo-link-firebase-performance-monitoring';

// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
  // ...
};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);

// Initialize Performance Monitoring and get a reference to the service
const perf = firebase.performance();

// ...
ApolloLink.from([
  createFPMLink(() => perf, true /* debug: true/false for logging to console */),
  // ...
]);
Do notice that you have to give a function that returns Firebase performance instance or undefined. Thats because the object is not available when using SSR. If you use debug logging you may also want to only activate it when in the browser environment so that you don't fill up the logs on your server.

License

This project is licensed under the MIT License - see the license file for details.