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
5b7127a3
Commit
5b7127a3
authored
Aug 18, 2020
by
Philip Cunningham
Committed by
Nick Thomas
Aug 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand scope of GraphQL pipeline resolver
Allow query to retrieve all pipelines rather than CI-only.
parent
8fc5347f
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
134 additions
and
1 deletion
+134
-1
app/graphql/resolvers/project_pipeline_resolver.rb
app/graphql/resolvers/project_pipeline_resolver.rb
+1
-1
app/graphql/types/ci/pipeline_config_source_enum.rb
app/graphql/types/ci/pipeline_config_source_enum.rb
+11
-0
app/graphql/types/ci/pipeline_type.rb
app/graphql/types/ci/pipeline_type.rb
+2
-0
changelogs/unreleased/null-pipeline-in-graphql-response-224687.yml
...s/unreleased/null-pipeline-in-graphql-response-224687.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+18
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+73
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-0
spec/graphql/resolvers/project_pipeline_resolver_spec.rb
spec/graphql/resolvers/project_pipeline_resolver_spec.rb
+17
-0
spec/requests/api/graphql/project/pipeline_spec.rb
spec/requests/api/graphql/project/pipeline_spec.rb
+6
-0
No files found.
app/graphql/resolvers/project_pipeline_resolver.rb
View file @
5b7127a3
...
...
@@ -10,7 +10,7 @@ module Resolvers
def
resolve
(
iid
:)
BatchLoader
::
GraphQL
.
for
(
iid
).
batch
(
key:
project
)
do
|
iids
,
loader
,
args
|
args
[
:key
].
ci
_pipelines
.
for_iid
(
iids
).
each
{
|
pl
|
loader
.
call
(
pl
.
iid
.
to_s
,
pl
)
}
args
[
:key
].
all
_pipelines
.
for_iid
(
iids
).
each
{
|
pl
|
loader
.
call
(
pl
.
iid
.
to_s
,
pl
)
}
end
end
end
...
...
app/graphql/types/ci/pipeline_config_source_enum.rb
0 → 100644
View file @
5b7127a3
# frozen_string_literal: true
module
Types
module
Ci
class
PipelineConfigSourceEnum
<
BaseEnum
::
Ci
::
PipelineEnums
.
config_sources
.
keys
.
each
do
|
state_symbol
|
value
state_symbol
.
to_s
.
upcase
,
value:
state_symbol
.
to_s
end
end
end
end
app/graphql/types/ci/pipeline_type.rb
View file @
5b7127a3
...
...
@@ -25,6 +25,8 @@ module Types
field
:detailed_status
,
Types
::
Ci
::
DetailedStatusType
,
null:
false
,
description:
'Detailed status of the pipeline'
,
resolve:
->
(
obj
,
_args
,
ctx
)
{
obj
.
detailed_status
(
ctx
[
:current_user
])
}
field
:config_source
,
PipelineConfigSourceEnum
,
null:
true
,
description:
"Config source of the pipeline (
#{
::
Ci
::
PipelineEnums
.
config_sources
.
keys
.
join
(
', '
).
upcase
}
)"
field
:duration
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Duration of the pipeline in seconds'
field
:coverage
,
GraphQL
::
FLOAT_TYPE
,
null:
true
,
...
...
changelogs/unreleased/null-pipeline-in-graphql-response-224687.yml
0 → 100644
View file @
5b7127a3
---
title
:
Allow GraphQL pipeline to resolve non-CI pipelines and expose configSource field
merge_request
:
39275
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
5b7127a3
...
...
@@ -10261,6 +10261,13 @@ type Pipeline {
"""
committedAt
:
Time
"""
Config
source
of
the
pipeline
(
UNKNOWN_SOURCE
,
REPOSITORY_SOURCE
,
AUTO_DEVOPS_SOURCE
,
WEBIDE_SOURCE
,
REMOTE_SOURCE
,
EXTERNAL_PROJECT_SOURCE
,
BRIDGE_SOURCE
,
PARAMETER_SOURCE
)
"""
configSource
:
PipelineConfigSourceEnum
"""
Coverage
percentage
"""
...
...
@@ -10353,6 +10360,17 @@ type Pipeline {
userPermissions
:
PipelinePermissions
!
}
enum
PipelineConfigSourceEnum
{
AUTO_DEVOPS_SOURCE
BRIDGE_SOURCE
EXTERNAL_PROJECT_SOURCE
PARAMETER_SOURCE
REMOTE_SOURCE
REPOSITORY_SOURCE
UNKNOWN_SOURCE
WEBIDE_SOURCE
}
"""
The connection type for Pipeline.
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
5b7127a3
...
...
@@ -30652,6 +30652,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "configSource",
"description": "Config source of the pipeline (UNKNOWN_SOURCE, REPOSITORY_SOURCE, AUTO_DEVOPS_SOURCE, WEBIDE_SOURCE, REMOTE_SOURCE, EXTERNAL_PROJECT_SOURCE, BRIDGE_SOURCE, PARAMETER_SOURCE)",
"args": [
],
"type": {
"kind": "ENUM",
"name": "PipelineConfigSourceEnum",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "coverage",
"description": "Coverage percentage",
...
...
@@ -30927,6 +30941,65 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "PipelineConfigSourceEnum",
"description": null,
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "UNKNOWN_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "REPOSITORY_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "AUTO_DEVOPS_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "WEBIDE_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "REMOTE_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "EXTERNAL_PROJECT_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "BRIDGE_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "PARAMETER_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "PipelineConnection",
doc/api/graphql/reference/index.md
View file @
5b7127a3
...
...
@@ -1571,6 +1571,7 @@ Information about pagination in a connection.
| --- | ---- | ---------- |
|
`beforeSha`
| String | Base SHA of the source branch |
|
`committedAt`
| Time | Timestamp of the pipeline's commit |
|
`configSource`
| PipelineConfigSourceEnum | Config source of the pipeline (UNKNOWN_SOURCE, REPOSITORY_SOURCE, AUTO_DEVOPS_SOURCE, WEBIDE_SOURCE, REMOTE_SOURCE, EXTERNAL_PROJECT_SOURCE, BRIDGE_SOURCE, PARAMETER_SOURCE) |
|
`coverage`
| Float | Coverage percentage |
|
`createdAt`
| Time! | Timestamp of the pipeline's creation |
|
`detailedStatus`
| DetailedStatus! | Detailed status of the pipeline |
...
...
spec/graphql/resolvers/project_pipeline_resolver_spec.rb
View file @
5b7127a3
...
...
@@ -33,4 +33,21 @@ RSpec.describe Resolvers::ProjectPipelineResolver do
it
'errors when no iid is passed'
do
expect
{
resolve_pipeline
(
project
,
{})
}.
to
raise_error
(
ArgumentError
)
end
context
'when the pipeline is not a ci_config_source'
do
let
(
:pipeline
)
do
config_source_value
=
Ci
::
PipelineEnums
.
non_ci_config_source_values
.
first
config_source
=
Ci
::
PipelineEnums
.
config_sources
.
key
(
config_source_value
)
create
(
:ci_pipeline
,
config_source:
config_source
,
project:
project
)
end
it
'resolves pipeline for the passed iid'
do
result
=
batch_sync
do
resolve_pipeline
(
project
,
{
iid:
pipeline
.
iid
.
to_s
})
end
expect
(
result
).
to
eq
(
pipeline
)
end
end
end
spec/requests/api/graphql/project/pipeline_spec.rb
View file @
5b7127a3
...
...
@@ -29,4 +29,10 @@ RSpec.describe 'getting pipeline information nested in a project' do
expect
(
pipeline_graphql_data
).
not_to
be_nil
end
it
'contains configSource'
do
post_graphql
(
query
,
current_user:
current_user
)
expect
(
pipeline_graphql_data
.
dig
(
'configSource'
)).
to
eq
(
'UNKNOWN_SOURCE'
)
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