2018-07-10 14:19:45 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Graphql
|
|
|
|
module MountMutation
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2018-08-27 12:35:31 +00:00
|
|
|
class_methods do
|
2019-06-26 10:42:25 +00:00
|
|
|
def mount_mutation(mutation_class, **custom_kwargs)
|
2018-07-10 14:19:45 +00: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 10:42:25 +00:00
|
|
|
mutation: mutation_class,
|
|
|
|
**custom_kwargs
|
2018-07-10 14:19:45 +00:00
|
|
|
end
|
2020-06-23 12:09:20 +00: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 14:19:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|