gitlab-org--gitlab-foss/lib/gitlab/graphql/copy_field_description.rb
Luke Duncalfe 4b9b2a43d0 GraphQL mutations for add, remove and toggle emoji
Adding new `AddAwardEmoji`, `RemoveAwardEmoji` and `ToggleAwardEmoji`
GraphQL mutations.

Adding new `#authorized_find_with_pre_checks!` and (unused, but for
completeness `#authorized_find_with_post_checks!`) authorization
methods. These allow us to perform an authorized find, and run our own
additional checks before or after the authorization runs.

https://gitlab.com/gitlab-org/gitlab-ce/issues/62826
2019-06-28 12:03:33 +12:00

21 lines
696 B
Ruby

# frozen_string_literal: true
module Gitlab
module Graphql
module CopyFieldDescription
extend ActiveSupport::Concern
class_methods do
# Returns the `description` for property of field `field_name` on type.
# This can be used to ensure, for example, that mutation argument descriptions
# are always identical to the corresponding query field descriptions.
#
# E.g.:
# argument :name, GraphQL::STRING_TYPE, description: copy_field_description(Types::UserType, :name)
def copy_field_description(type, field_name)
type.fields[field_name.to_s.camelize(:lower)].description
end
end
end
end
end