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

dast_profile_connection_extension.rb « project « graphql « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a3c3f2f2b7ec8d1496064366ebf58a664ad1293a (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 Project
      class DastProfileConnectionExtension < GraphQL::Schema::Field::ConnectionExtension
        def after_resolve(value:, object:, context:, **rest)
          preload_authorizations(context[:project_dast_profiles])
          context[:project_dast_profiles] = nil
          value
        end

        def preload_authorizations(dast_profiles)
          return unless dast_profiles

          projects = dast_profiles.map(&:project)
          users = dast_profiles.filter_map { |dast_profile| dast_profile.dast_profile_schedule&.owner }
          Preloaders::UsersMaxAccessLevelInProjectsPreloader.new(projects: projects, users: users).execute
        end
      end
    end
  end
end