@apollo/utils.usagereporting
Generate a signature for Apollo usage reporting
Last updated 3 years ago by apollo-bot .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @apollo/utils.usagereporting 
SYNC missed versions from official npm registry.

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).

Current Tags

  • 2.0.0                                ...           latest (3 years ago)

3 Versions

  • 2.0.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dev Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |