Skip to content
This repository has been archived by the owner on May 22, 2022. It is now read-only.

Firebase Performance Monitoring for Apollo GraphQL Client using Apollo Link

License

Notifications You must be signed in to change notification settings

Gerrel/apollo-link-firebase-performance-monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apollo-link-firebase-performance-monitoring

Firebase Performance Monitoring for Apollo GraphQL Client using Apollo Link

version downloads MIT License Watch on GitHub Star on GitHub

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.