2019-06-21 00:45:27 -04:00
|
|
|
# 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.:
|
2021-07-23 14:10:06 -04:00
|
|
|
# argument :name, GraphQL::Types::String, description: copy_field_description(Types::UserType, :name)
|
2019-06-21 00:45:27 -04:00
|
|
|
def copy_field_description(type, field_name)
|
|
|
|
type.fields[field_name.to_s.camelize(:lower)].description
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|