Sha256: 91a20d746ab21483eb647a1644efc53f83bb35c6ed4e457e10fd5d45744ad1c3

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require 'graphql_rails/controller/action'
require 'graphql_rails/concerns/service'
require 'graphql_rails/controller/action_configuration'
require 'graphql_rails/controller/build_controller_action_resolver/controller_action_resolver'

module GraphqlRails
  class Controller
    # graphql resolver which redirects actions to appropriate controller and controller action
    class BuildControllerActionResolver
      include ::GraphqlRails::Service

      def initialize(route:)
        @route = route
      end

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

        Class.new(ControllerActionResolver) do
          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

      private

      attr_reader :route

      def build_action
        Action.new(route).tap do |action|
          assert_action(action)
        end
      end

      def assert_action(action)
        action.return_type
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
graphql_rails-2.2.0 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-2.1.0 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-2.0.0 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-1.2.6 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-1.2.4 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-1.2.3 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-1.2.2 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-1.2.1 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-1.2.0 lib/graphql_rails/controller/build_controller_action_resolver.rb
graphql_rails-1.1.0 lib/graphql_rails/controller/build_controller_action_resolver.rb