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
30918929
Commit
30918929
authored
Feb 13, 2019
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement singular iid for IssuesResolver and ProjectType
parent
564b86a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
4 deletions
+16
-4
app/graphql/resolvers/issues_resolver.rb
app/graphql/resolvers/issues_resolver.rb
+4
-1
app/graphql/resolvers/merge_requests_resolver.rb
app/graphql/resolvers/merge_requests_resolver.rb
+3
-3
app/graphql/types/project_type.rb
app/graphql/types/project_type.rb
+5
-0
spec/graphql/resolvers/issues_resolver_spec.rb
spec/graphql/resolvers/issues_resolver_spec.rb
+4
-0
No files found.
app/graphql/resolvers/issues_resolver.rb
View file @
30918929
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
module
Resolvers
module
Resolvers
class
IssuesResolver
<
BaseResolver
class
IssuesResolver
<
BaseResolver
extend
ActiveSupport
::
Concern
argument
:iid
,
GraphQL
::
ID_TYPE
,
required:
false
,
description:
'The IID of the issue, e.g., "1"'
argument
:iids
,
[
GraphQL
::
ID_TYPE
],
argument
:iids
,
[
GraphQL
::
ID_TYPE
],
required:
false
,
required:
false
,
...
@@ -22,6 +24,7 @@ module Resolvers
...
@@ -22,6 +24,7 @@ module Resolvers
# Will need to be be made group & namespace aware with
# Will need to be be made group & namespace aware with
# https://gitlab.com/gitlab-org/gitlab-ce/issues/54520
# https://gitlab.com/gitlab-org/gitlab-ce/issues/54520
args
[
:project_id
]
=
project
.
id
args
[
:project_id
]
=
project
.
id
args
[
:iids
]
||=
[
args
[
:iid
]].
compact
IssuesFinder
.
new
(
context
[
:current_user
],
args
).
execute
IssuesFinder
.
new
(
context
[
:current_user
],
args
).
execute
end
end
...
...
app/graphql/resolvers/merge_requests_resolver.rb
View file @
30918929
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
module
Resolvers
module
Resolvers
class
MergeRequestsResolver
<
BaseResolver
class
MergeRequestsResolver
<
BaseResolver
argument
:iid
,
GraphQL
::
ID_TYPE
,
argument
:iid
,
GraphQL
::
ID_TYPE
,
required:
false
,
required:
false
,
description:
'The IID of the merge request, e.g., "1"'
description:
'The IID of the merge request, e.g., "1"'
argument
:iids
,
[
GraphQL
::
ID_TYPE
],
argument
:iids
,
[
GraphQL
::
ID_TYPE
],
required:
false
,
required:
false
,
...
@@ -17,7 +17,7 @@ module Resolvers
...
@@ -17,7 +17,7 @@ module Resolvers
def
resolve
(
**
args
)
def
resolve
(
**
args
)
return
unless
project
.
present?
return
unless
project
.
present?
args
[
:iids
]
||=
[
args
[
:iid
]]
args
[
:iids
]
||=
[
args
[
:iid
]]
.
compact
args
[
:iids
].
map
(
&
method
(
:batch_load
))
args
[
:iids
].
map
(
&
method
(
:batch_load
))
.
select
(
&
:itself
)
# .compact doesn't work on BatchLoader
.
select
(
&
:itself
)
# .compact doesn't work on BatchLoader
...
...
app/graphql/types/project_type.rb
View file @
30918929
...
@@ -85,6 +85,11 @@ module Types
...
@@ -85,6 +85,11 @@ module Types
null:
true
,
null:
true
,
resolver:
Resolvers
::
IssuesResolver
resolver:
Resolvers
::
IssuesResolver
field
:issue
,
Types
::
IssueType
,
null:
true
,
resolver:
Resolvers
::
IssuesResolver
.
single
field
:pipelines
,
field
:pipelines
,
Types
::
Ci
::
PipelineType
.
connection_type
,
Types
::
Ci
::
PipelineType
.
connection_type
,
null:
false
,
null:
false
,
...
...
spec/graphql/resolvers/issues_resolver_spec.rb
View file @
30918929
...
@@ -33,6 +33,10 @@ describe Resolvers::IssuesResolver do
...
@@ -33,6 +33,10 @@ describe Resolvers::IssuesResolver do
expect
(
resolve_issues
).
to
contain_exactly
(
issue
,
issue2
)
expect
(
resolve_issues
).
to
contain_exactly
(
issue
,
issue2
)
end
end
it
'finds a specific issue with iid'
do
expect
(
resolve_issues
(
iid:
issue
.
iid
)).
to
contain_exactly
(
issue
)
end
it
'finds a specific issue with iids'
do
it
'finds a specific issue with iids'
do
expect
(
resolve_issues
(
iids:
issue
.
iid
)).
to
contain_exactly
(
issue
)
expect
(
resolve_issues
(
iids:
issue
.
iid
)).
to
contain_exactly
(
issue
)
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