module GraphQL::PersistedQueries

Plugin definition

Constants

VERSION

Public Class Methods

configure_compiled_queries() click to toggle source

rubocop:enable Metrics/MethodLength

# File lib/graphql/persisted_queries.rb, line 40
def self.configure_compiled_queries
  if Gem::Dependency.new("graphql", "< 1.12.0").match?("graphql", GraphQL::VERSION)
    raise ArgumentError, "compiled_queries are not supported for graphql-ruby < 1.12.0"
  end

  GraphQL::Execution::Multiplex.singleton_class.prepend(
    GraphQL::PersistedQueries::CompiledQueries::MultiplexPatch
  )

  GraphQL::Query.prepend(GraphQL::PersistedQueries::CompiledQueries::QueryPatch)
end
use(schema_defn, **options) click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/graphql/persisted_queries.rb, line 19
def self.use(schema_defn, **options)
  schema = schema_defn.is_a?(Class) ? schema_defn : schema_defn.target

  compiled_queries = options.delete(:compiled_queries)
  SchemaPatch.patch(schema, compiled_queries)
  configure_compiled_queries if compiled_queries

  schema.hash_generator = options.delete(:hash_generator) || :sha256

  schema.verify_http_method = options.delete(:verify_http_method)

  error_handler = options.delete(:error_handler) || :default
  schema.configure_persisted_query_error_handler(error_handler)

  schema.persisted_queries_tracing_enabled = options.delete(:tracing)

  store = options.delete(:store) || :memory
  schema.configure_persisted_query_store(store, **options)
end