Commit b497bc21 authored by Alex Kalderimis's avatar Alex Kalderimis

Add rich deprecations to enums

parent bf1d0bd3
...@@ -2,7 +2,19 @@ ...@@ -2,7 +2,19 @@
module Types module Types
class BaseEnum < GraphQL::Schema::Enum 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 class << self
# Registers enum definition by the given DeclarativeEnum module # Registers enum definition by the given DeclarativeEnum module
...@@ -41,7 +53,6 @@ module Types ...@@ -41,7 +53,6 @@ module Types
def value(*args, **kwargs, &block) def value(*args, **kwargs, &block)
enum[args[0].downcase] = kwargs[:value] || args[0] enum[args[0].downcase] = kwargs[:value] || args[0]
gitlab_deprecation(kwargs)
super(*args, **kwargs, &block) super(*args, **kwargs, &block)
end end
......
...@@ -14561,11 +14561,16 @@ State of a Sentry error. ...@@ -14561,11 +14561,16 @@ State of a Sentry error.
| Value | Description | | Value | Description |
| ----- | ----------- | | ----- | ----------- |
| <a id="servicetypeasana_integration"></a>`ASANA_INTEGRATION` | AsanaIntegration integration. |
| <a id="servicetypeasana_service"></a>`ASANA_SERVICE` | AsanaService type. | | <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="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="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="servicetypebugzilla_service"></a>`BUGZILLA_SERVICE` | BugzillaService type. |
| <a id="servicetypebuildkite_service"></a>`BUILDKITE_SERVICE` | BuildkiteService 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="servicetypecampfire_service"></a>`CAMPFIRE_SERVICE` | CampfireService type. |
| <a id="servicetypeconfluence_service"></a>`CONFLUENCE_SERVICE` | ConfluenceService type. | | <a id="servicetypeconfluence_service"></a>`CONFLUENCE_SERVICE` | ConfluenceService type. |
| <a id="servicetypecustom_issue_tracker_service"></a>`CUSTOM_ISSUE_TRACKER_SERVICE` | CustomIssueTrackerService type. | | <a id="servicetypecustom_issue_tracker_service"></a>`CUSTOM_ISSUE_TRACKER_SERVICE` | CustomIssueTrackerService type. |
......
...@@ -41,7 +41,7 @@ module Gitlab ...@@ -41,7 +41,7 @@ module Gitlab
parts = [ parts = [
"#{deprecated_in(format: :markdown)}.", "#{deprecated_in(format: :markdown)}.",
reason_text, reason_text,
replacement.then { |r| "Use: [`#{r}`](##{r.downcase.tr('.', '')})." if r } replacement_markdown.then { |r| "Use: #{r}." if r }
].compact ].compact
case context case context
...@@ -52,6 +52,13 @@ module Gitlab ...@@ -52,6 +52,13 @@ module Gitlab
end end
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) def edit_description(original_description)
@original_description = original_description @original_description = original_description
return unless original_description return unless original_description
......
...@@ -411,14 +411,18 @@ module Gitlab ...@@ -411,14 +411,18 @@ module Gitlab
mapping = {} mapping = {}
schema.types.each do |type_name, type| schema.types.each do |type_name, type|
next unless type.kind.fields? if type.kind.fields?
type.fields.each do |field_name, field| type.fields.each do |field_name, field|
mapping["#{type_name}.#{field_name}"] = field.try(:deprecation) mapping["#{type_name}.#{field_name}"] = field.try(:deprecation)
field.arguments.each do |arg_name, arg| field.arguments.each do |arg_name, arg|
mapping["#{type_name}.#{field_name}.#{arg_name}"] = arg.try(:deprecation) mapping["#{type_name}.#{field_name}.#{arg_name}"] = arg.try(:deprecation)
end end
end end
elsif type.kind.enum?
type.values.each do |member_name, enum|
mapping["#{type_name}.#{member_name}"] = enum.try(:deprecation)
end
end
end end
mapping.compact mapping.compact
......
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