summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-29 21:10:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-29 21:10:03 +0000
commit1785d4e4aa1834e39c6d46527076d0f9054e329f (patch)
tree577894a97f873f6ce57181badc29a4814f5ef193 /lib
parent71dc16a12c2b0aaeee3a8fa55aa1ca880f5699b4 (diff)
downloadgitlab-ce-1785d4e4aa1834e39c6d46527076d0f9054e329f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/graphql/docs/helper.rb30
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/gitlab/graphql/docs/helper.rb b/lib/gitlab/graphql/docs/helper.rb
index 5274b2ee3ba..b598b605141 100644
--- a/lib/gitlab/graphql/docs/helper.rb
+++ b/lib/gitlab/graphql/docs/helper.rb
@@ -267,7 +267,7 @@ module Gitlab
if deprecated?(object, owner)
render_deprecation(object, owner, context)
else
- render_description_of(object)
+ render_description_of(object, owner, context)
end
end
@@ -278,7 +278,7 @@ module Gitlab
deprecations.key?(key)
end
- def render_description_of(object)
+ def render_description_of(object, owner, context = nil)
desc = if object[:is_edge]
base = object[:name].chomp('Edge')
"The edge type for [`#{base}`](##{base.downcase})."
@@ -292,14 +292,31 @@ module Gitlab
return if desc.blank?
desc += '.' unless desc.ends_with?('.')
+ see = doc_reference(object, owner)
+ desc += " #{see}" if see
+ desc += " (see [Connections](#connections))" if connection?(object) && context != :block
desc
end
+ def doc_reference(object, owner)
+ field = schema_field(owner, object[:name]) if owner
+ return unless field
+
+ ref = field.try(:doc_reference)
+ return if ref.blank?
+
+ parts = ref.to_a.map do |(title, url)|
+ "[#{title.strip}](#{url.strip})"
+ end
+
+ "See #{parts.join(', ')}."
+ end
+
def render_deprecation(object, owner, context)
buff = []
deprecation = schema_deprecation(owner, object[:name])
- buff << (deprecation&.original_description || render_description_of(object)) if context == :block
+ buff << (deprecation&.original_description || render_description_of(object, owner)) if context == :block
buff << if deprecation
deprecation.markdown(context: context)
else
@@ -382,6 +399,13 @@ module Gitlab
"Input type: `#{input_field[:type][:name]}`"
end
+ def schema_field(type_name, field_name)
+ type = schema.types[type_name]
+ return unless type && type.kind.fields?
+
+ type.fields[field_name]
+ end
+
def deprecations
strong_memoize(:deprecations) do
mapping = {}