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

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Result


10
11
12
13
14
15
# File 'lib/graphql/relay/mutation/result.rb', line 10

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 Attribute Details

.mutationObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


18
19
20
# File 'lib/graphql/relay/mutation/result.rb', line 18

def mutation
  @mutation
end

Instance Attribute Details

#client_mutation_idObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
# File 'lib/graphql/relay/mutation/result.rb', line 9

def client_mutation_id
  @client_mutation_id
end

Class Method Details

.define_subclass(mutation_defn) ⇒ Class

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build a subclass whose instances have a method for each of mutation_defn's return_fields

Parameters:

Returns:

  • (Class)

25
26
27
28
29
30
31
32
33
34
# File 'lib/graphql/relay/mutation/result.rb', line 25

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