Class: GraphQL::Relay::Mutation::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/relay/mutation.rb

Overview

Use this when the mutation's return type was generated from return_fields. It delegates field lookups to the hash returned from resolve.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_mutation_id:, result:) ⇒ Result


149
150
151
152
153
154
# File 'lib/graphql/relay/mutation.rb', line 149

def initialize(client_mutation_id:, result:)
  @client_mutation_id = client_mutation_id
  result.each do |key, value|
    self.public_send("#{key}=", value)
  end
end

Class Attribute Details

.mutationObject

Returns the value of attribute mutation


157
158
159
# File 'lib/graphql/relay/mutation.rb', line 157

def mutation
  @mutation
end

Instance Attribute Details

#client_mutation_idObject (readonly)

Returns the value of attribute client_mutation_id


148
149
150
# File 'lib/graphql/relay/mutation.rb', line 148

def client_mutation_id
  @client_mutation_id
end

Class Method Details

.define_subclass(mutation_defn) ⇒ Object


160
161
162
163
164
165
166
# File 'lib/graphql/relay/mutation.rb', line 160

def self.define_subclass(mutation_defn)
  subclass = Class.new(self) do
    attr_accessor(*mutation_defn.return_type.all_fields.map(&:name))
    self.mutation = mutation_defn
  end
  subclass
end