summaryrefslogtreecommitdiff
path: root/app/graphql/types/merge_request_type.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2019-06-20 08:02:33 +0000
committerDouwe Maan <douwe@gitlab.com>2019-06-20 08:02:33 +0000
commit406808583c2392a0b57f68f98b2418e9d23b23ab (patch)
tree98613723a6caf6dc152f9ff431e75906ebe2c5ca /app/graphql/types/merge_request_type.rb
parentadeccba13676b831335e2f12f779f77602298b31 (diff)
downloadgitlab-ce-406808583c2392a0b57f68f98b2418e9d23b23ab.tar.gz
Render GFM html in GraphQL
This adds a `markdown_field` to our types. Using this helper will render a model's markdown field using the existing `MarkupHelper` with the context of the GraphQL query available to the helper. Having the context available to the helper is needed for redacting links to resources that the current user is not allowed to see. Because rendering the HTML can cause queries, the complexity of a these fields is raised by 5 above the default. The markdown field helper can be used as follows: ``` markdown_field :note_html, null: false ``` This would generate a field that will render the markdown field `note` of the model. This could be overridden by adding the `method:` argument. Passing a symbol for the method name: ``` markdown_field :body_html, null: false, method: :note ``` It will have this description by default: > The GitLab Flavored Markdown rendering of `note` This could be overridden by passing a `description:` argument. The type of a `markdown_field` is always `GraphQL::STRING_TYPE`.
Diffstat (limited to 'app/graphql/types/merge_request_type.rb')
-rw-r--r--app/graphql/types/merge_request_type.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb
index dac4c24cf10..577ccd48ef8 100644
--- a/app/graphql/types/merge_request_type.rb
+++ b/app/graphql/types/merge_request_type.rb
@@ -15,7 +15,9 @@ module Types
field :id, GraphQL::ID_TYPE, null: false
field :iid, GraphQL::STRING_TYPE, null: false
field :title, GraphQL::STRING_TYPE, null: false
+ markdown_field :title_html, null: true
field :description, GraphQL::STRING_TYPE, null: true
+ markdown_field :description_html, null: true
field :state, MergeRequestStateEnum, null: false
field :created_at, Types::TimeType, null: false
field :updated_at, Types::TimeType, null: false