Commit a6009287 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch 'remove-preloader-field-extension-todos' into 'master'

Remove TodosProjectPermissionPreloader field extension

See merge request gitlab-org/gitlab!68895
parents e62710d7 e86abb2b
......@@ -30,6 +30,13 @@ module Resolvers
required: false,
description: 'Type of the todo.'
before_connection_authorization do |nodes, current_user|
Preloaders::UserMaxAccessLevelInProjectsPreloader.new(
nodes.map(&:project).compact,
current_user
).execute
end
def resolve(**args)
return Todo.none unless current_user.present? && target.present?
return Todo.none if target.is_a?(User) && target != current_user
......
......@@ -115,9 +115,7 @@ module Types
null: true,
description: 'Runbook for the alert as defined in alert details.'
field :todos, description: 'To-do items of the current user for the alert.', resolver: Resolvers::TodoResolver do
extension(::Gitlab::Graphql::TodosProjectPermissionPreloader::FieldExtension)
end
field :todos, description: 'To-do items of the current user for the alert.', resolver: Resolvers::TodoResolver
field :details_url,
GraphQL::Types::String,
......
......@@ -85,9 +85,7 @@ module Types
null: true,
description: 'Personal namespace of the user.'
field :todos, resolver: Resolvers::TodoResolver, description: 'To-do items of the user.' do
extension(::Gitlab::Graphql::TodosProjectPermissionPreloader::FieldExtension)
end
field :todos, resolver: Resolvers::TodoResolver, description: 'To-do items of the user.'
# Merge request field: MRs can be authored, assigned, or assigned-for-review:
field :authored_merge_requests,
......
# frozen_string_literal: true
module Gitlab
module Graphql
module TodosProjectPermissionPreloader
class FieldExtension < ::GraphQL::Schema::FieldExtension
def after_resolve(value:, memo:, **rest)
todos = value.to_a
Preloaders::UserMaxAccessLevelInProjectsPreloader.new(
todos.map(&:project).compact,
current_user(rest)
).execute
value
end
private
def current_user(options)
options.dig(:context, :current_user)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment