Sha256: 064de91742789a7cfb0f567adc6022444f019675f34d3b237234eafd0a6ddeae
Contents?: true
Size: 1.07 KB
Versions: 178
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module GraphQL module Define module AssignMutationFunction def self.call(target, function) # TODO: get all this logic somewhere easier to test if !function.type.is_a?(GraphQL::ObjectType) raise "Mutation functions must return object types (not #{function.type.unwrap})" end target.return_type = function.type.redefine { name(target.name + "Payload") field :clientMutationId, types.String, "A unique identifier for the client performing the mutation.", property: :client_mutation_id } target.arguments = function.arguments target.description = function.description target.resolve = ->(o, a, c) { res = function.call(o, a, c) ResultProxy.new(res, a[:clientMutationId]) } end class ResultProxy < SimpleDelegator attr_reader :client_mutation_id def initialize(target, client_mutation_id) @client_mutation_id = client_mutation_id super(target) end end end end end
Version data entries
178 entries across 178 versions & 2 rubygems