Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b497bc21
Commit
b497bc21
authored
May 25, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add rich deprecations to enums
parent
bf1d0bd3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
9 deletions
+36
-9
app/graphql/types/base_enum.rb
app/graphql/types/base_enum.rb
+13
-2
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+5
-0
lib/gitlab/graphql/deprecation.rb
lib/gitlab/graphql/deprecation.rb
+8
-1
lib/gitlab/graphql/docs/helper.rb
lib/gitlab/graphql/docs/helper.rb
+10
-6
No files found.
app/graphql/types/base_enum.rb
View file @
b497bc21
...
...
@@ -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
...
...
doc/api/graphql/reference/index.md
View file @
b497bc21
...
...
@@ -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. |
...
...
lib/gitlab/graphql/deprecation.rb
View file @
b497bc21
...
...
@@ -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
...
...
lib/gitlab/graphql/docs/helper.rb
View file @
b497bc21
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment