Class: GraphQL::PersistedQueries::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/persisted_queries/resolver.rb

Overview

Fetches or stores query string in the storage

Defined Under Namespace

Classes: NotFound, WrongHash

Instance Method Summary collapse

Constructor Details

#initialize(extensions, schema) ⇒ Resolver

Returns a new instance of Resolver.



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

def initialize(extensions, schema)
  @extensions = extensions
  @schema = schema
end

Instance Method Details

#resolve(query_str) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/graphql/persisted_queries/resolver.rb', line 26

def resolve(query_str)
  return query_str if hash.nil?

  if query_str
    persist_query(query_str)
  else
    query_str = with_error_handling { @schema.persisted_query_store.fetch_query(hash) }
    raise NotFound if query_str.nil?
  end

  query_str
end