Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mount_mutation.rb « graphql « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8e507ba4531006d4e81b6f78b8dc78cfd88bf2be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Gitlab
  module Graphql
    module MountMutation
      extend ActiveSupport::Concern

      class_methods do
        def mount_mutation(mutation_class, **custom_kwargs)
          # Using an underscored field name symbol will make `graphql-ruby`
          # standardize the field name
          field mutation_class.graphql_name.underscore.to_sym,
                mutation: mutation_class,
                **custom_kwargs
        end

        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
      end
    end
  end
end