Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apollo/utils.usagereporting

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apollo/utils.usagereporting

Generate a signature for Apollo usage reporting

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
decreased by-9.92%
Maintainers
4
Weekly downloads
 
Created
Source

usageReporting

This package exports the useful bits of usage reporting related to signature computation and referenced field calculation.

usageReportingSignature

In Apollo Studio, we want to group requests making the same query together, and treat different queries distinctly. But what does it mean for two queries to be "the same"? And what if you don't want to send the full text of the query to Apollo's servers, either because it contains sensitive data orw because it contains extraneous operations or fragments?

To solve these problems, Apollo Studio and related components have the concept of "signatures". We don't (by default) send the full query string of queries to Apollo's servers. Instead, each trace has its query string's "signature".

The usageReportingSignature function is a combination of the following transforms:

  • dropUnusedDefinitions: removes operations and fragments that aren't going to be used in execution
  • stripSensitiveLiterals: replaces all numeric and string literals as well as list and object input values with "empty" values
  • removeAliases: removes field aliasing from the operation
  • sortAST: sorts the children of most multi-child nodes consistently
  • printWithReducedWhitespace, a variant on graphql-js's print which gets rid of unneeded whitespace

calculateReferencedFieldsByType

Given a DocumentNode (operation) and a GraphQLSchema, calculateReferencedFieldsByType constructs a record of typeName -> { fieldNames: string[], isInterface: boolean }. This record is the field usage data sent to Apollo Studio keyed by operation signature (usageReportingSignature).

Keywords

FAQs

Package last updated on 05 Jun 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc