Module: GraphQL::Schema::Member::HasDeprecationReason Private

Included in:
Argument, EnumValue, Field
Defined in:
lib/graphql/schema/member/has_deprecation_reason.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#deprecation_reasonString?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Explains why this member was deprecated (if present, this will be marked deprecated in introspection).

Returns:

  • (String, nil)

    Explains why this member was deprecated (if present, this will be marked deprecated in introspection)



8
9
10
11
# File 'lib/graphql/schema/member/has_deprecation_reason.rb', line 8

def deprecation_reason
  dir = self.directives.find { |d| d.is_a?(GraphQL::Schema::Directive::Deprecated) }
  dir && dir.arguments[:reason] # rubocop:disable Development/ContextIsPassedCop -- definition-related
end

#deprecation_reason=(text) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set the deprecation reason for this member, or remove it by assigning nil

Parameters:

  • text (String, nil)


15
16
17
18
19
20
21
# File 'lib/graphql/schema/member/has_deprecation_reason.rb', line 15

def deprecation_reason=(text)
  if text.nil?
    remove_directive(GraphQL::Schema::Directive::Deprecated)
  else
    directive(GraphQL::Schema::Directive::Deprecated, reason: text)
  end
end