summaryrefslogtreecommitdiff
path: root/lib/gitlab/graphql/markdown_field/resolver.rb
blob: 11a01b95ad133800f3240cdc80a64f438832e60e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module Gitlab
  module Graphql
    module MarkdownField
      class Resolver
        attr_reader :method_name

        def initialize(method_name)
          @method_name = method_name
        end

        def proc
          -> (object, _args, ctx) do
            # We need to `dup` the context so the MarkdownHelper doesn't modify it
            ::MarkupHelper.markdown_field(object, method_name, ctx.to_h.dup)
          end
        end
      end
    end
  end
end