Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e86abb2b
Commit
e86abb2b
authored
Aug 24, 2021
by
Mario Celi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove TodosProjectPermissionPreloader field extension
Use before_connection_authorization resolver block instead
parent
8cb37e68
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
32 deletions
+9
-32
app/graphql/resolvers/todo_resolver.rb
app/graphql/resolvers/todo_resolver.rb
+7
-0
app/graphql/types/alert_management/alert_type.rb
app/graphql/types/alert_management/alert_type.rb
+1
-3
app/graphql/types/user_interface.rb
app/graphql/types/user_interface.rb
+1
-3
lib/gitlab/graphql/todos_project_permission_preloader/field_extension.rb
...hql/todos_project_permission_preloader/field_extension.rb
+0
-26
No files found.
app/graphql/resolvers/todo_resolver.rb
View file @
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
...
...
app/graphql/types/alert_management/alert_type.rb
View file @
e86abb2b
...
...
@@ -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
,
...
...
app/graphql/types/user_interface.rb
View file @
e86abb2b
...
...
@@ -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
,
...
...
lib/gitlab/graphql/todos_project_permission_preloader/field_extension.rb
deleted
100644 → 0
View file @
8cb37e68
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment