class GraphqlRails::Controller::Request
Contains all info related with single request to controller
Attributes
context[R]
errors[R]
graphql_object[R]
inputs[R]
object_to_return[RW]
Public Class Methods
new(graphql_object, inputs, context)
click to toggle source
# File lib/graphql_rails/controller/request.rb, line 12 def initialize(graphql_object, inputs, context) @graphql_object = graphql_object @inputs = inputs @context = context end
Public Instance Methods
errors=(new_errors)
click to toggle source
# File lib/graphql_rails/controller/request.rb, line 18 def errors=(new_errors) @errors = FormatErrors.call(not_formatted_errors: new_errors) @errors.each { |error| context.add_error(error) } end
no_object_to_return?()
click to toggle source
# File lib/graphql_rails/controller/request.rb, line 24 def no_object_to_return? !defined?(@object_to_return) end
params()
click to toggle source
# File lib/graphql_rails/controller/request.rb, line 28 def params deep_transform_values(inputs.to_h) do |val| graphql_object_to_hash(val) end end
Private Instance Methods
deep_transform_values(hash) { |val| ... }
click to toggle source
# File lib/graphql_rails/controller/request.rb, line 48 def deep_transform_values(hash, &block) return hash unless hash.is_a?(Hash) hash.transform_values do |val| if val.is_a?(Hash) deep_transform_values(val, &block) else yield(val) end end end
graphql_object_to_hash(object)
click to toggle source
# File lib/graphql_rails/controller/request.rb, line 38 def graphql_object_to_hash(object) if object.is_a?(GraphQL::Dig) object.to_h elsif object.is_a?(Array) object.map { |item| graphql_object_to_hash(item) } else object end end