Sha256: e800f481b79200bce50d6efda8a03dbcb1fa761864eedd71dabaeeab85081748

Contents?: true

Size: 1.17 KB

Versions: 170

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true
module GraphQL
  module Relay
    class Mutation
      # Use this when the mutation's return type was generated from `return_field`s.
      # It delegates field lookups to the hash returned from `resolve`.
      # @api private
      class Result
        attr_reader :client_mutation_id
        def initialize(client_mutation_id:, result:)
          @client_mutation_id = client_mutation_id
          result && result.each do |key, value|
            self.public_send("#{key}=", value)
          end
        end

        class << self
          attr_accessor :mutation
        end

        # Build a subclass whose instances have a method
        # for each of `mutation_defn`'s `return_field`s
        # @param mutation_defn [GraphQL::Relay::Mutation]
        # @return [Class]
        def self.define_subclass(mutation_defn)
          subclass = Class.new(self) do
            mutation_result_methods = mutation_defn.return_type.all_fields.map do |f|
              f.property || f.name
            end
            attr_accessor(*mutation_result_methods)
            self.mutation = mutation_defn
          end
          subclass
        end
      end
    end
  end
end

Version data entries

170 entries across 170 versions & 2 rubygems

Version Path
graphql-1.11.12 lib/graphql/relay/mutation/result.rb
graphql-1.11.11 lib/graphql/relay/mutation/result.rb
graphql-1.12.25 lib/graphql/relay/mutation/result.rb
graphql-1.13.24 lib/graphql/relay/mutation/result.rb
graphql-1.13.23 lib/graphql/relay/mutation/result.rb
graphql-1.13.22 lib/graphql/relay/mutation/result.rb
graphql-1.13.21 lib/graphql/relay/mutation/result.rb
graphql-1.13.20 lib/graphql/relay/mutation/result.rb
graphql-1.13.19 lib/graphql/relay/mutation/result.rb
graphql-1.13.18 lib/graphql/relay/mutation/result.rb
graphql-1.13.17 lib/graphql/relay/mutation/result.rb
graphql-1.13.16 lib/graphql/relay/mutation/result.rb
graphql-1.13.15 lib/graphql/relay/mutation/result.rb
graphql-1.13.14 lib/graphql/relay/mutation/result.rb
graphql-1.13.13 lib/graphql/relay/mutation/result.rb
graphql_cody-1.13.0 lib/graphql/relay/mutation/result.rb
graphql-1.13.12 lib/graphql/relay/mutation/result.rb
graphql-1.13.11 lib/graphql/relay/mutation/result.rb
graphql-1.13.10 lib/graphql/relay/mutation/result.rb
graphql-1.13.9 lib/graphql/relay/mutation/result.rb