Class: GraphqlRails::Controller::BuildControllerActionResolver

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
lib/graphql_rails/controller/build_controller_action_resolver.rb,
lib/graphql_rails/controller/build_controller_action_resolver/controller_action_resolver.rb

Overview

graphql resolver which redirects actions to appropriate controller and controller action

Defined Under Namespace

Classes: ControllerActionResolver

Instance Method Summary collapse

Constructor Details

#initialize(action:) ⇒ BuildControllerActionResolver

Returns a new instance of BuildControllerActionResolver.



13
14
15
# File 'lib/graphql_rails/controller/build_controller_action_resolver.rb', line 13

def initialize(action:)
  @action = action
end

Instance Method Details

#callObject

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/graphql_rails/controller/build_controller_action_resolver.rb', line 17

def call # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  action = self.action

  Class.new(ControllerActionResolver) do
    graphql_name("ControllerActionResolver#{SecureRandom.hex}")

    type(*action.type_args, **action.type_options)
    description(action.description)
    controller(action.controller)
    controller_action_name(action.name)

    action.arguments.each do |attribute|
      argument(*attribute.input_argument_args, **attribute.input_argument_options)
    end

    def self.inspect
      "ControllerActionResolver(#{controller.name}##{controller_action_name})"
    end
  end
end