Sha256: 5be76ab1acad318daab2d2494bae4597a84d8fc68738da1cd00ce4c49cd36503

Contents?: true

Size: 822 Bytes

Versions: 6

Compression:

Stored size: 822 Bytes

Contents

# frozen_string_literal: true

module Rails # :nodoc:
  module GraphQL # :nodoc:
    class Request # :nodoc:
      # Helper methods for the resolve step of a request
      module Resolveable
        # Resolve the object
        def resolve!
          capture_exception(:resolve) { resolve }
        end

        protected

          # Normal mode of the resolve step
          def resolve
            invalid? ? try(:resolve_invalid) : resolve_then
          end

          # The actual process that resolve the object
          def resolve_then(after_block = nil, &block)
            return if invalid?
            stacked do
              block.call if block.present?
              trigger_event(:finalize)
              after_block.call if after_block.present?
            end
          end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-graphql-0.2.1 lib/rails/graphql/request/steps/resolveable.rb
rails-graphql-0.2.0 lib/rails/graphql/request/steps/resolveable.rb
rails-graphql-0.1.3 lib/rails/graphql/request/steps/resolveable.rb
rails-graphql-0.1.2 lib/rails/graphql/request/steps/resolveable.rb
rails-graphql-0.1.1 lib/rails/graphql/request/steps/resolveable.rb
rails-graphql-0.1.0 lib/rails/graphql/request/steps/resolveable.rb