Commit dd534ff4 authored by Mike Jang's avatar Mike Jang

Merge branch 'ld-docs-query-type-fixes' into 'master'

GraphQL API reference docs: Query type fixes

See merge request gitlab-org/gitlab!55336
parents 9b284083 7a74ba12
This diff is collapsed.
...@@ -28,7 +28,7 @@ module Gitlab ...@@ -28,7 +28,7 @@ module Gitlab
end end
def render_name_and_description(object) def render_name_and_description(object)
content = "### #{object[:name].camelcase}\n" content = "### #{object[:name]}\n"
if object[:description].present? if object[:description].present?
content += "\n#{object[:description]}" content += "\n#{object[:description]}"
...@@ -53,14 +53,6 @@ module Gitlab ...@@ -53,14 +53,6 @@ module Gitlab
] ]
end end
def render_argument(argument)
'| %s | %s | %s |' % [
render_name(argument),
render_description(argument),
render_field_type(argument[:type][:info])
]
end
def render_enum_value(value) def render_enum_value(value)
'| %s | %s |' % [ '| %s | %s |' % [
render_name(value), render_name(value),
......
...@@ -21,21 +21,19 @@ ...@@ -21,21 +21,19 @@
\ \
:plain :plain
## Queries ## `Query` type
Queries are used to get the resources, filter or query them. The `Query` type contains the API's top-level entry points for all executable queries.
For more information, visit [Queries and Mutations](https://graphql.org/learn/queries/).
\ \
- sorted_by_name(queries).each do |query| - sorted_by_name(queries).each do |query|
= render_name_and_description(query) = render_name_and_description(query)
- unless query[:arguments].empty? - unless query[:arguments].empty?
~ "| Name | Description | Type |" ~ "#### Arguments\n"
~ "| ----- | ---- | ----------- |" ~ "| Name | Type | Description |"
~ "| ---- | ---- | ----------- |"
- sorted_by_name(query[:arguments]).each do |argument| - sorted_by_name(query[:arguments]).each do |argument|
= render_argument(argument) = render_field(argument)
\ \
:plain :plain
......
...@@ -53,13 +53,15 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do ...@@ -53,13 +53,15 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
context 'query generation' do context 'query generation' do
let(:expectation) do let(:expectation) do
<<~DOC <<~DOC
### Foo ### foo
List of objects. List of objects.
| Name | Description | Type | #### Arguments
| ----- | ---- | ----------- |
| `id` | ID of the object. | ID | | Name | Type | Description |
| ---- | ---- | ----------- |
| `id` | ID | ID of the object. |
DOC DOC
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