Class: GraphQL::Relay::Mutation::MutationResolve

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

Instance Method Summary collapse

Constructor Details

#initialize(mutation, resolve, wrap_result:) ⇒ MutationResolve


173
174
175
176
177
# File 'lib/graphql/relay/mutation.rb', line 173

def initialize(mutation, resolve, wrap_result:)
  @mutation = mutation
  @resolve = resolve
  @wrap_result = wrap_result
end

Instance Method Details

#call(obj, args, ctx) ⇒ Object


179
180
181
182
183
184
185
186
# File 'lib/graphql/relay/mutation.rb', line 179

def call(obj, args, ctx)
  mutation_result = @resolve.call(obj, args[:input], ctx)
  if @wrap_result
    @mutation.result_class.new(client_mutation_id: args[:input][:clientMutationId], result: mutation_result)
  else
    mutation_result
  end
end