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

module Gitlab
  module Graphql
    class Lazy
      # Force evaluation of a (possibly) lazy value
      def self.force(value)
        case value
        when ::BatchLoader::GraphQL
          value.sync
        when ::Concurrent::Promise
          value.execute.value
        else
          value
        end
      end
    end
  end
end