Commit b497bc21 authored by Alex Kalderimis's avatar Alex Kalderimis

Add rich deprecations to enums

parent bf1d0bd3
......@@ -2,7 +2,19 @@
module Types
class BaseEnum < GraphQL::Schema::Enum
extend GitlabStyleDeprecations
class CustomValue < GraphQL::Schema::EnumValue
include ::GitlabStyleDeprecations
attr_reader :deprecation
def initialize(name, desc = nil, **kwargs)
@deprecation = gitlab_deprecation(kwargs)
super(name, desc, **kwargs)
end
end
enum_value_class(CustomValue)
class << self
# Registers enum definition by the given DeclarativeEnum module
......@@ -41,7 +53,6 @@ module Types
def value(*args, **kwargs, &block)
enum[args[0].downcase] = kwargs[:value] || args[0]
gitlab_deprecation(kwargs)
super(*args, **kwargs, &block)
end
......
......@@ -14561,11 +14561,16 @@ State of a Sentry error.
| Value | Description |
| ----- | ----------- |
| <a id="servicetypeasana_integration"></a>`ASANA_INTEGRATION` | AsanaIntegration integration. |
| <a id="servicetypeasana_service"></a>`ASANA_SERVICE` | AsanaService type. |
| <a id="servicetypeassembla_integration"></a>`ASSEMBLA_INTEGRATION` | AssemblaIntegration integration. |
| <a id="servicetypeassembla_service"></a>`ASSEMBLA_SERVICE` | AssemblaService type. |
| <a id="servicetypebamboo_integration"></a>`BAMBOO_INTEGRATION` | BambooIntegration integration. |
| <a id="servicetypebamboo_service"></a>`BAMBOO_SERVICE` | BambooService type. |
| <a id="servicetypebugzilla_integration"></a>`BUGZILLA_INTEGRATION` | BugzillaIntegration integration. |
| <a id="servicetypebugzilla_service"></a>`BUGZILLA_SERVICE` | BugzillaService type. |
| <a id="servicetypebuildkite_service"></a>`BUILDKITE_SERVICE` | BuildkiteService type. |
| <a id="servicetypecampfire_integration"></a>`CAMPFIRE_INTEGRATION` | CampfireIntegration integration. |
| <a id="servicetypecampfire_service"></a>`CAMPFIRE_SERVICE` | CampfireService type. |
| <a id="servicetypeconfluence_service"></a>`CONFLUENCE_SERVICE` | ConfluenceService type. |
| <a id="servicetypecustom_issue_tracker_service"></a>`CUSTOM_ISSUE_TRACKER_SERVICE` | CustomIssueTrackerService type. |
......
......@@ -41,7 +41,7 @@ module Gitlab
parts = [
"#{deprecated_in(format: :markdown)}.",
reason_text,
replacement.then { |r| "Use: [`#{r}`](##{r.downcase.tr('.', '')})." if r }
replacement_markdown.then { |r| "Use: #{r}." if r }
].compact
case context
......@@ -52,6 +52,13 @@ module Gitlab
end
end
def replacement_markdown
return unless replacement.present?
return "`#{replacement}`" unless replacement.include?('.') # only fully qualified references can be linked
"[`#{replacement}`](##{replacement.downcase.tr('.', '')})"
end
def edit_description(original_description)
@original_description = original_description
return unless original_description
......
......@@ -411,12 +411,16 @@ module Gitlab
mapping = {}
schema.types.each do |type_name, type|
next unless type.kind.fields?
type.fields.each do |field_name, field|
mapping["#{type_name}.#{field_name}"] = field.try(:deprecation)
field.arguments.each do |arg_name, arg|
mapping["#{type_name}.#{field_name}.#{arg_name}"] = arg.try(:deprecation)
if type.kind.fields?
type.fields.each do |field_name, field|
mapping["#{type_name}.#{field_name}"] = field.try(:deprecation)
field.arguments.each do |arg_name, arg|
mapping["#{type_name}.#{field_name}.#{arg_name}"] = arg.try(:deprecation)
end
end
elsif type.kind.enum?
type.values.each do |member_name, enum|
mapping["#{type_name}.#{member_name}"] = enum.try(:deprecation)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment