Module: GraphQL::PersistedQueries::SchemaPatch
- Defined in:
- lib/graphql/persisted_queries/schema_patch.rb
Overview
Patches GraphQL::Schema to support persisted queries
Instance Attribute Summary collapse
-
#hash_generator_proc ⇒ Object
readonly
Returns the value of attribute hash_generator_proc.
-
#persisted_query_store ⇒ Object
readonly
Returns the value of attribute persisted_query_store.
Instance Method Summary collapse
- #configure_persisted_query_store(store, options) ⇒ Object
- #execute(query_str = nil, **kwargs) ⇒ Object
- #hash_generator=(hash_generator) ⇒ Object
Instance Attribute Details
#hash_generator_proc ⇒ Object (readonly)
Returns the value of attribute hash_generator_proc.
10 11 12 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 10 def hash_generator_proc @hash_generator_proc end |
#persisted_query_store ⇒ Object (readonly)
Returns the value of attribute persisted_query_store.
10 11 12 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 10 def persisted_query_store @persisted_query_store end |
Instance Method Details
#configure_persisted_query_store(store, options) ⇒ Object
12 13 14 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 12 def configure_persisted_query_store(store, ) @persisted_query_store = StoreAdapters.build(store, ) end |
#execute(query_str = nil, **kwargs) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 20 def execute(query_str = nil, **kwargs) if (extensions = kwargs.delete(:extensions)) resolver = Resolver.new(extensions, persisted_query_store, hash_generator_proc) query_str = resolver.resolve(query_str) end super rescue Resolver::NotFound, Resolver::WrongHash => e { errors: [{ message: e. }] } end |
#hash_generator=(hash_generator) ⇒ Object
16 17 18 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 16 def hash_generator=(hash_generator) @hash_generator_proc = HashGeneratorBuilder.new(hash_generator).build end |