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_queries_tracing_enabled ⇒ Object
writeonly
Sets the attribute persisted_queries_tracing_enabled.
-
#persisted_query_error_handler ⇒ Object
readonly
Returns the value of attribute persisted_query_error_handler.
-
#persisted_query_store ⇒ Object
readonly
Returns the value of attribute persisted_query_store.
Class Method Summary collapse
Instance Method Summary collapse
- #configure_persisted_query_error_handler(handler) ⇒ Object
- #configure_persisted_query_store(store, options) ⇒ Object
- #hash_generator=(hash_generator) ⇒ Object
- #multiplex(queries, **kwargs) ⇒ Object
- #persisted_queries_tracing_enabled? ⇒ Boolean
- #tracer(name) ⇒ Object
- #verify_http_method=(verify) ⇒ Object
Instance Attribute Details
#hash_generator_proc ⇒ Object (readonly)
Returns the value of attribute hash_generator_proc.
19 20 21 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 19 def hash_generator_proc @hash_generator_proc end |
#persisted_queries_tracing_enabled=(value) ⇒ Object (writeonly)
Sets the attribute persisted_queries_tracing_enabled
20 21 22 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 20 def persisted_queries_tracing_enabled=(value) @persisted_queries_tracing_enabled = value end |
#persisted_query_error_handler ⇒ Object (readonly)
Returns the value of attribute persisted_query_error_handler.
19 20 21 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 19 def persisted_query_error_handler @persisted_query_error_handler end |
#persisted_query_store ⇒ Object (readonly)
Returns the value of attribute persisted_query_store.
19 20 21 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 19 def persisted_query_store @persisted_query_store end |
Class Method Details
.patch(schema) ⇒ Object
13 14 15 16 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 13 def patch(schema) schema.singleton_class.class_eval { alias_method :multiplex_original, :multiplex } schema.singleton_class.prepend(SchemaPatch) end |
Instance Method Details
#configure_persisted_query_error_handler(handler) ⇒ Object
28 29 30 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 28 def configure_persisted_query_error_handler(handler) @persisted_query_error_handler = ErrorHandlers.build(handler) end |
#configure_persisted_query_store(store, options) ⇒ Object
22 23 24 25 26 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 22 def configure_persisted_query_store(store, ) @persisted_query_store = StoreAdapters.build(store, ).tap do |adapter| adapter.tracers = tracers if persisted_queries_tracing_enabled? end end |
#hash_generator=(hash_generator) ⇒ Object
32 33 34 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 32 def hash_generator=(hash_generator) @hash_generator_proc = HashGeneratorBuilder.new(hash_generator).build end |
#multiplex(queries, **kwargs) ⇒ Object
50 51 52 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 50 def multiplex(queries, **kwargs) MultiplexResolver.new(self, queries, kwargs).resolve end |
#persisted_queries_tracing_enabled? ⇒ Boolean
46 47 48 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 46 def persisted_queries_tracing_enabled? @persisted_queries_tracing_enabled end |
#tracer(name) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 54 def tracer(name) super.tap do # Since tracers can be set before *and* after our plugin hooks in, # we need to set tracers both when this plugin gets initialized # and any time a tracer is added after initialization persisted_query_store.tracers = tracers if persisted_queries_tracing_enabled? end end |
#verify_http_method=(verify) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/graphql/persisted_queries/schema_patch.rb', line 36 def verify_http_method=(verify) return unless verify if graphql10? query_analyzer(prepare_analyzer) else query_analyzers << prepare_analyzer end end |