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
5e9bd39f
Commit
5e9bd39f
authored
Jul 30, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add issuable state count type for Project grpahql
- reuse issue resolver fields - Use IssuablesCountForState
parent
2bef64c0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
126 additions
and
54 deletions
+126
-54
app/graphql/resolvers/issue_resolver_fields.rb
app/graphql/resolvers/issue_resolver_fields.rb
+61
-0
app/graphql/resolvers/issue_status_counts_resolver.rb
app/graphql/resolvers/issue_status_counts_resolver.rb
+26
-0
app/graphql/resolvers/issues_resolver.rb
app/graphql/resolvers/issues_resolver.rb
+1
-51
app/graphql/types/issue_status_counts_type.rb
app/graphql/types/issue_status_counts_type.rb
+17
-0
app/graphql/types/project_type.rb
app/graphql/types/project_type.rb
+8
-2
lib/gitlab/issuables_count_for_state.rb
lib/gitlab/issuables_count_for_state.rb
+13
-1
No files found.
app/graphql/resolvers/issue_resolver_fields.rb
0 → 100644
View file @
5e9bd39f
# frozen_string_literal: true
module
Resolvers
module
IssueResolverFields
extend
ActiveSupport
::
Concern
prepended
do
argument
:iid
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'IID of the issue. For example, "1"'
argument
:iids
,
[
GraphQL
::
STRING_TYPE
],
required:
false
,
description:
'List of IIDs of issues. For example, [1, 2]'
argument
:state
,
Types
::
IssuableStateEnum
,
required:
false
,
description:
'Current state of this issue'
argument
:label_name
,
GraphQL
::
STRING_TYPE
.
to_list_type
,
required:
false
,
description:
'Labels applied to this issue'
argument
:milestone_title
,
GraphQL
::
STRING_TYPE
.
to_list_type
,
required:
false
,
description:
'Milestones applied to this issue'
argument
:assignee_username
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Username of a user assigned to the issues'
argument
:assignee_id
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'ID of a user assigned to the issues, "none" and "any" values supported'
argument
:created_before
,
Types
::
TimeType
,
required:
false
,
description:
'Issues created before this date'
argument
:created_after
,
Types
::
TimeType
,
required:
false
,
description:
'Issues created after this date'
argument
:updated_before
,
Types
::
TimeType
,
required:
false
,
description:
'Issues updated before this date'
argument
:updated_after
,
Types
::
TimeType
,
required:
false
,
description:
'Issues updated after this date'
argument
:closed_before
,
Types
::
TimeType
,
required:
false
,
description:
'Issues closed before this date'
argument
:closed_after
,
Types
::
TimeType
,
required:
false
,
description:
'Issues closed after this date'
argument
:search
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Search query for issue title or description'
argument
:sort
,
Types
::
IssueSortEnum
,
description:
'Sort issues by this criteria'
,
required:
false
,
default_value:
'created_desc'
argument
:types
,
[
Types
::
IssueTypeEnum
],
as: :issue_types
,
description:
'Filter issues by the given issue types'
,
required:
false
end
end
end
app/graphql/resolvers/issue_status_counts_resolver.rb
0 → 100644
View file @
5e9bd39f
# frozen_string_literal: true
module
Resolvers
class
IssueStatusCountsResolver
<
BaseResolver
prepend
Resolvers
::
IssueResolverFields
type
Types
::
IssueStatusCountsType
,
null:
true
def
resolve
(
**
args
)
# The project could have been loaded in batch by `BatchLoader`.
# At this point we need the `id` of the project to query for issues, so
# make sure it's loaded and not `nil` before continuing.
parent
=
object
.
respond_to?
(
:sync
)
?
object
.
sync
:
object
return
Issue
.
none
if
parent
.
nil?
# Will need to be be made group & namespace aware with
# https://gitlab.com/gitlab-org/gitlab-foss/issues/54520
args
[
:iids
]
||=
[
args
.
delete
(
:iid
)].
compact
if
args
[
:iid
]
args
[
:attempt_project_search_optimizations
]
=
true
if
args
[
:search
].
present?
finder
=
IssuesFinder
.
new
(
current_user
,
args
)
Gitlab
::
IssuablesCountForState
.
new
(
finder
,
parent
)
end
end
end
app/graphql/resolvers/issues_resolver.rb
View file @
5e9bd39f
...
...
@@ -2,57 +2,7 @@
module
Resolvers
class
IssuesResolver
<
BaseResolver
argument
:iid
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'IID of the issue. For example, "1"'
argument
:iids
,
[
GraphQL
::
STRING_TYPE
],
required:
false
,
description:
'List of IIDs of issues. For example, [1, 2]'
argument
:state
,
Types
::
IssuableStateEnum
,
required:
false
,
description:
'Current state of this issue'
argument
:label_name
,
GraphQL
::
STRING_TYPE
.
to_list_type
,
required:
false
,
description:
'Labels applied to this issue'
argument
:milestone_title
,
GraphQL
::
STRING_TYPE
.
to_list_type
,
required:
false
,
description:
'Milestones applied to this issue'
argument
:assignee_username
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Username of a user assigned to the issues'
argument
:assignee_id
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'ID of a user assigned to the issues, "none" and "any" values supported'
argument
:created_before
,
Types
::
TimeType
,
required:
false
,
description:
'Issues created before this date'
argument
:created_after
,
Types
::
TimeType
,
required:
false
,
description:
'Issues created after this date'
argument
:updated_before
,
Types
::
TimeType
,
required:
false
,
description:
'Issues updated before this date'
argument
:updated_after
,
Types
::
TimeType
,
required:
false
,
description:
'Issues updated after this date'
argument
:closed_before
,
Types
::
TimeType
,
required:
false
,
description:
'Issues closed before this date'
argument
:closed_after
,
Types
::
TimeType
,
required:
false
,
description:
'Issues closed after this date'
argument
:search
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Search query for issue title or description'
argument
:sort
,
Types
::
IssueSortEnum
,
description:
'Sort issues by this criteria'
,
required:
false
,
default_value:
'created_desc'
argument
:types
,
[
Types
::
IssueTypeEnum
],
as: :issue_types
,
description:
'Filter issues by the given issue types'
,
required:
false
prepend
Resolvers
::
IssueResolverFields
type
Types
::
IssueType
,
null:
true
...
...
app/graphql/types/issue_status_counts_type.rb
0 → 100644
View file @
5e9bd39f
# frozen_string_literal: true
module
Types
class
IssueStatusCountsType
<
BaseObject
graphql_name
'IssueStatusCountsType'
description
"Represents total number of issues for the represented categories"
authorize
:read_issue
::
Gitlab
::
IssuablesCountForState
::
STATES
.
each
do
|
status
|
field
status
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
"Number of issues with status
#{
status
.
upcase
}
for the project"
end
end
end
app/graphql/types/project_type.rb
View file @
5e9bd39f
...
...
@@ -148,6 +148,12 @@ module Types
description:
'Issues of the project'
,
resolver:
Resolvers
::
IssuesResolver
field
:issue_status_counts
,
Types
::
IssueStatusCountsType
,
null:
true
,
description:
'Counts of issues by status for the project'
,
resolver:
Resolvers
::
IssueStatusCountsResolver
field
:milestones
,
Types
::
MilestoneType
.
connection_type
,
null:
true
,
description:
'Milestones of the project'
,
resolver:
Resolvers
::
ProjectMilestonesResolver
...
...
@@ -164,8 +170,8 @@ module Types
resolver:
Resolvers
::
EnvironmentsResolver
field
:sast_ci_configuration
,
::
Types
::
CiConfiguration
::
Sast
::
Type
,
null:
true
,
description:
'SAST CI configuration for the project'
,
resolver:
::
Resolvers
::
CiConfiguration
::
SastResolver
description:
'SAST CI configuration for the project'
,
resolver:
::
Resolvers
::
CiConfiguration
::
SastResolver
field
:issue
,
Types
::
IssueType
,
...
...
lib/gitlab/issuables_count_for_state.rb
View file @
5e9bd39f
...
...
@@ -9,9 +9,16 @@ module Gitlab
# The state values that can be safely casted to a Symbol.
STATES
=
%w[opened closed merged all]
.
freeze
attr_reader
:project
def
self
.
declarative_policy_class
'IssuablePolicy'
end
# finder - The finder class to use for retrieving the issuables.
def
initialize
(
finder
)
def
initialize
(
finder
,
project
=
nil
)
@finder
=
finder
@project
=
project
@cache
=
Gitlab
::
SafeRequestStore
[
CACHE_KEY
]
||=
initialize_cache
end
...
...
@@ -19,6 +26,11 @@ module Gitlab
self
[
state
||
:opened
]
end
# Define method for each status
STATES
.
each
do
|
status
|
define_method
(
status
)
{
self
[
status
]
}
end
# Returns the count for the given state.
#
# state - The name of the state as either a String or a Symbol.
...
...
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