Welcome to mirror list, hosted at ThFree Co, Russian Federation.

notes_resolver.rb « noteable « resolvers « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0d25c747ffb81a6712786cf53fae7bbb16edb647 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

module Resolvers
  module Noteable
    class NotesResolver < BaseResolver
      include LooksAhead

      type Types::Notes::NoteType.connection_type, null: false

      before_connection_authorization do |nodes, current_user|
        next if nodes.blank?

        # For all noteables where we use this resolver, we can assume that all notes will belong to the same project
        project = nodes.first.project

        ::Preloaders::Projects::NotesPreloader.new(project, current_user).call(nodes)
      end

      def resolve_with_lookahead(*)
        apply_lookahead(object.notes.fresh)
      end

      private

      def unconditional_includes
        [:author, :project]
      end

      def preloads
        {
          award_emoji: [:award_emoji]
        }
      end
    end
  end
end