Class: GraphqlRails::Controller::BuildControllerActionResolver::ControllerActionResolver

Inherits:
GraphQL::Schema::Resolver
  • Object
show all
Defined in:
lib/graphql_rails/controller/build_controller_action_resolver/controller_action_resolver.rb

Overview

Resolver which includes controller specific methods. Used to simplify resolver build for each controller action

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.controller(controller_class = nil) ⇒ Object



14
15
16
17
# File 'lib/graphql_rails/controller/build_controller_action_resolver/controller_action_resolver.rb', line 14

def self.controller(controller_class = nil)
  @controller = controller_class if controller_class
  @controller
end

.controller_action_name(name = nil) ⇒ Object



19
20
21
22
# File 'lib/graphql_rails/controller/build_controller_action_resolver/controller_action_resolver.rb', line 19

def self.controller_action_name(name = nil)
  @controller_action_name = name if name
  @controller_action_name
end

Instance Method Details

#resolve(**inputs) ⇒ Object



24
25
26
27
# File 'lib/graphql_rails/controller/build_controller_action_resolver/controller_action_resolver.rb', line 24

def resolve(**inputs)
  request = Request.new(object, inputs, context)
  self.class.controller.new(request).call(self.class.controller_action_name)
end