Sha256: 0c3ba25e1a69861b7daf32e6690682ae771cd6f73e1ce776c5a3be59cea643ee

Contents?: true

Size: 855 Bytes

Versions: 9

Compression:

Stored size: 855 Bytes

Contents

# frozen_string_literal: true

require 'graphql_rails/controller/request'

module GraphqlRails
  class Controller
    class BuildControllerActionResolver
      # Resolver which includes controller specific methods.
      # Used to simplify resolver build for each controller action
      class ControllerActionResolver < GraphQL::Schema::Resolver
        def self.controller(controller_class = nil)
          @controller = controller_class if controller_class
          @controller
        end

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

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