debian-mirror-gitlab/lib/gitlab/graphql/project/dast_profile_connection_extension.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
751 B
Ruby
Raw Normal View History

2022-04-04 11:22:00 +05:30
# frozen_string_literal: true
module Gitlab
module Graphql
module Project
2022-06-21 17:19:12 +05:30
class DastProfileConnectionExtension < GraphQL::Schema::FieldExtension
2022-04-04 11:22:00 +05:30
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