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
be636a20
Commit
be636a20
authored
Sep 17, 2020
by
Maxime Orefice
Committed by
Robert Speicher
Sep 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Query projects by ids
This commit allows our GraphQL API to query projects by ids.
parent
d81fd9e9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
1 deletion
+45
-1
app/graphql/resolvers/projects_resolver.rb
app/graphql/resolvers/projects_resolver.rb
+9
-1
changelogs/unreleased/mo-graphql-query-projects-by-ids.yml
changelogs/unreleased/mo-graphql-query-projects-by-ids.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+5
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+18
-0
spec/graphql/resolvers/projects_resolver_spec.rb
spec/graphql/resolvers/projects_resolver_spec.rb
+8
-0
No files found.
app/graphql/resolvers/projects_resolver.rb
View file @
be636a20
...
@@ -12,9 +12,13 @@ module Resolvers
...
@@ -12,9 +12,13 @@ module Resolvers
required:
false
,
required:
false
,
description:
'Search query for project name, path, or description'
description:
'Search query for project name, path, or description'
argument
:ids
,
[
GraphQL
::
ID_TYPE
],
required:
false
,
description:
'Filter projects by IDs'
def
resolve
(
**
args
)
def
resolve
(
**
args
)
ProjectsFinder
ProjectsFinder
.
new
(
current_user:
current_user
,
params:
project_finder_params
(
args
))
.
new
(
current_user:
current_user
,
params:
project_finder_params
(
args
)
,
project_ids_relation:
parse_gids
(
args
[
:ids
])
)
.
execute
.
execute
end
end
...
@@ -27,5 +31,9 @@ module Resolvers
...
@@ -27,5 +31,9 @@ module Resolvers
search:
params
[
:search
]
search:
params
[
:search
]
}.
compact
}.
compact
end
end
def
parse_gids
(
gids
)
gids
&
.
map
{
|
gid
|
GitlabSchema
.
parse_gid
(
gid
,
expected_type:
::
Project
).
model_id
}
end
end
end
end
end
changelogs/unreleased/mo-graphql-query-projects-by-ids.yml
0 → 100644
View file @
be636a20
---
title
:
Query projects by ids with GraphQL
merge_request
:
42372
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
be636a20
...
@@ -13981,6 +13981,11 @@ type Query {
...
@@ -13981,6 +13981,11 @@ type Query {
"""
"""
first
:
Int
first
:
Int
"""
Filter
projects
by
IDs
"""
ids
:
[
ID
!]
"""
"""
Returns
the
last
_n_
elements
from
the
list
.
Returns
the
last
_n_
elements
from
the
list
.
"""
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
be636a20
...
@@ -40936,6 +40936,24 @@
...
@@ -40936,6 +40936,24 @@
},
},
"defaultValue": null
"defaultValue": null
},
},
{
"name": "ids",
"description": "Filter projects by IDs",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
},
{
{
"name": "after",
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"description": "Returns the elements in the list that come after the specified cursor.",
spec/graphql/resolvers/projects_resolver_spec.rb
View file @
be636a20
...
@@ -71,6 +71,14 @@ RSpec.describe Resolvers::ProjectsResolver do
...
@@ -71,6 +71,14 @@ RSpec.describe Resolvers::ProjectsResolver do
is_expected
.
to
contain_exactly
(
project
,
private_project
)
is_expected
.
to
contain_exactly
(
project
,
private_project
)
end
end
end
end
context
'when ids filter is provided'
do
let
(
:filters
)
{
{
ids:
[
project
.
to_global_id
.
to_s
]
}
}
it
'returns matching project'
do
is_expected
.
to
contain_exactly
(
project
)
end
end
end
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