summaryrefslogtreecommitdiff
path: root/lib/gitlab/graphql
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 18:09:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 18:09:21 +0000
commite0fa0638a422c3e20d4423c9bb69d79afc9c7d3d (patch)
tree9abb3c0706576bbda895fe9539a55556930606e2 /lib/gitlab/graphql
parentf8d15ca65390475e356b06dedc51e10ccd179f86 (diff)
downloadgitlab-ce-e0fa0638a422c3e20d4423c9bb69d79afc9c7d3d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/graphql')
-rw-r--r--lib/gitlab/graphql/docs/helper.rb22
-rw-r--r--lib/gitlab/graphql/docs/templates/default.md.haml5
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/gitlab/graphql/docs/helper.rb b/lib/gitlab/graphql/docs/helper.rb
index 56524120ffd..0dd28b32511 100644
--- a/lib/gitlab/graphql/docs/helper.rb
+++ b/lib/gitlab/graphql/docs/helper.rb
@@ -25,6 +25,28 @@ module Gitlab
fields.sort_by { |field| field[:name] }
end
+ def render_field(field)
+ '| %s | %s | %s |' % [
+ render_field_name(field),
+ render_field_type(field[:type][:info]),
+ render_field_description(field)
+ ]
+ end
+
+ def render_field_name(field)
+ rendered_name = "`#{field[:name]}`"
+ rendered_name += ' **{warning-solid}**' if field[:is_deprecated]
+ rendered_name
+ end
+
+ # Returns the field description. If the field has been deprecated,
+ # the deprecation reason will be returned in place of the description.
+ def render_field_description(field)
+ return field[:description] unless field[:is_deprecated]
+
+ "**Deprecated:** #{field[:deprecation_reason]}"
+ end
+
# Some fields types are arrays of other types and are displayed
# on docs wrapped in square brackets, for example: [String!].
# This makes GitLab docs renderer thinks they are links so here
diff --git a/lib/gitlab/graphql/docs/templates/default.md.haml b/lib/gitlab/graphql/docs/templates/default.md.haml
index b126a22c301..8c033526557 100644
--- a/lib/gitlab/graphql/docs/templates/default.md.haml
+++ b/lib/gitlab/graphql/docs/templates/default.md.haml
@@ -11,6 +11,9 @@
Each table below documents a GraphQL type. Types match loosely to models, but not all
fields and methods on a model are available via GraphQL.
+
+ CAUTION: **Caution:**
+ Fields that are deprecated are marked with **{warning-solid}**.
\
- objects.each do |type|
- unless type[:fields].empty?
@@ -22,5 +25,5 @@
~ "| Name | Type | Description |"
~ "| --- | ---- | ---------- |"
- sorted_fields(type[:fields]).each do |field|
- = "| `#{field[:name]}` | #{render_field_type(field[:type][:info])} | #{field[:description]} |"
+ = render_field(field)
\