module GraphQL::PersistedQueries::SchemaPatch

Patches GraphQL::Schema to support persisted queries

Attributes

persisted_queries_tracing_enabled[W]

Public Class Methods

patch(schema, compiled_queries) click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 13
def patch(schema, compiled_queries)
  schema.singleton_class.prepend(SchemaPatch)

  return if compiled_queries

  schema.singleton_class.class_eval { alias_method :multiplex_original, :multiplex }
  schema.singleton_class.prepend(MultiplexPatch)
end

Public Instance Methods

configure_persisted_query_error_handler(handler) click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 46
def configure_persisted_query_error_handler(handler)
  @persisted_query_error_handler = ErrorHandlers.build(handler)
end
configure_persisted_query_store(store, **options) click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 32
def configure_persisted_query_store(store, **options)
  @persisted_query_store = StoreAdapters.build(store, **options).tap do |adapter|
    adapter.tracers = tracers if persisted_queries_tracing_enabled?
  end
end
hash_generator=(hash_generator) click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 50
def hash_generator=(hash_generator)
  @hash_generator_proc = HashGeneratorBuilder.new(hash_generator).build
end
hash_generator_proc() click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 54
def hash_generator_proc
  @hash_generator_proc ||= find_inherited_value(:hash_generator_proc)
end
persisted_queries_tracing_enabled?() click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 62
def persisted_queries_tracing_enabled?
  @persisted_queries_tracing_enabled ||=
    find_inherited_value(:persisted_queries_tracing_enabled?)
end
persisted_query_error_handler() click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 42
def persisted_query_error_handler
  @persisted_query_error_handler ||= find_inherited_value(:persisted_query_error_handler)
end
persisted_query_store() click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 38
def persisted_query_store
  @persisted_query_store ||= find_inherited_value(:persisted_query_store)
end
tracer(name) click to toggle source
Calls superclass method
# File lib/graphql/persisted_queries/schema_patch.rb, line 67
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) click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 58
def verify_http_method=(verify)
  query_analyzer(prepare_analyzer) if verify
end

Private Instance Methods

prepare_analyzer() click to toggle source
# File lib/graphql/persisted_queries/schema_patch.rb, line 78
def prepare_analyzer
  if using_ast_analysis?
    require "graphql/persisted_queries/analyzers/http_method_ast_analyzer"
    Analyzers::HttpMethodAstAnalyzer
  else
    require "graphql/persisted_queries/analyzers/http_method_analyzer"
    Analyzers::HttpMethodAnalyzer.new
  end
end