Module: GraphQL::Query::Fingerprint Private

Defined in:
lib/graphql/query/fingerprint.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

See Also:

Class Method Summary collapse

Class Method Details

.generate(input_str) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Make an obfuscated hash of the given string (either a query string or variables JSON)

Parameters:

  • string (String)

Returns:

  • (String)

    A normalized, opaque hash



15
16
17
18
19
20
21
22
23
# File 'lib/graphql/query/fingerprint.rb', line 15

def self.generate(input_str)
  # Implemented to be:
  # - Short (and uniform) length
  # - Stable
  # - Irreversibly Opaque (don't want to leak variable values)
  # - URL-friendly
  bytes = Digest::SHA256.digest(input_str)
  Base64.urlsafe_encode64(bytes)
end