Module: GraphQL::PersistedQueries::ResolverHelpers

Included in:
CompiledQueries::Resolver, Resolver
Defined in:
lib/graphql/persisted_queries/resolver_helpers.rb

Overview

Helper functions for resolvers

Class Method Summary collapse

Class Method Details

.hashObject



21
22
23
# File 'lib/graphql/persisted_queries/resolver_helpers.rb', line 21

def hash
  @hash ||= @extensions.dig("persistedQuery", "sha256Hash")
end

.validate_hash!(query_string) ⇒ Object



15
16
17
18
19
# File 'lib/graphql/persisted_queries/resolver_helpers.rb', line 15

def validate_hash!(query_string)
  return if @schema.hash_generator_proc.call(query_string) == hash

  raise GraphQL::PersistedQueries::WrongHash
end

.with_error_handlingObject



9
10
11
12
13
# File 'lib/graphql/persisted_queries/resolver_helpers.rb', line 9

def with_error_handling
  yield
rescue StandardError => e
  @schema.persisted_query_error_handler.call(e)
end