debian-mirror-gitlab/lib/gitlab/graphql/mount_mutation.rb

28 lines
773 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
module Gitlab
module Graphql
module MountMutation
extend ActiveSupport::Concern
2018-11-20 20:47:30 +05:30
class_methods do
2019-09-30 21:07:59 +05:30
def mount_mutation(mutation_class, **custom_kwargs)
2018-11-18 11:00:15 +05:30
# Using an underscored field name symbol will make `graphql-ruby`
# standardize the field name
field mutation_class.graphql_name.underscore.to_sym,
2019-09-30 21:07:59 +05:30
mutation: mutation_class,
**custom_kwargs
2018-11-18 11:00:15 +05:30
end
2020-07-28 23:09:34 +05:30
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-11-18 11:00:15 +05:30
end
end
end
end