2018-07-10 10:19:45 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Graphql
|
|
|
|
module MountMutation
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2018-08-27 08:35:31 -04:00
|
|
|
class_methods do
|
2019-06-26 06:42:25 -04:00
|
|
|
def mount_mutation(mutation_class, **custom_kwargs)
|
2018-07-10 10:19:45 -04:00
|
|
|
# Using an underscored field name symbol will make `graphql-ruby`
|
|
|
|
# standardize the field name
|
|
|
|
field mutation_class.graphql_name.underscore.to_sym,
|
2019-06-26 06:42:25 -04:00
|
|
|
mutation: mutation_class,
|
|
|
|
**custom_kwargs
|
2018-07-10 10:19:45 -04:00
|
|
|
end
|
2020-06-23 08:09:20 -04:00
|
|
|
|
|
|
|
def mount_aliased_mutation(alias_name, mutation_class, **custom_kwargs)
|
|
|
|
aliased_mutation_class = Class.new(mutation_class) do
|
|
|
|
graphql_name alias_name
|
|
|
|
end
|
|
|
|
|
|
|
|
mount_mutation(aliased_mutation_class, **custom_kwargs)
|
|
|
|
end
|
2018-07-10 10:19:45 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|