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
45c09e5d
Commit
45c09e5d
authored
May 14, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add search to the resolver
- add specs - update docs
parent
f0bce4cb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
16 deletions
+52
-16
app/graphql/resolvers/alert_management_alert_resolver.rb
app/graphql/resolvers/alert_management_alert_resolver.rb
+4
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+10
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+20
-0
spec/requests/api/graphql/project/alert_management/alerts_spec.rb
...uests/api/graphql/project/alert_management/alerts_spec.rb
+18
-16
No files found.
app/graphql/resolvers/alert_management_alert_resolver.rb
View file @
45c09e5d
...
...
@@ -15,6 +15,10 @@ module Resolvers
description:
'Sort alerts by this criteria'
,
required:
false
argument
:search
,
GraphQL
::
STRING_TYPE
,
description:
'Search criteria for filtering alerts. This will search on title, description, service, monitoring_tool.'
,
required:
false
type
Types
::
AlertManagement
::
AlertType
,
null:
true
def
resolve
(
**
args
)
...
...
doc/api/graphql/reference/gitlab_schema.graphql
View file @
45c09e5d
...
...
@@ -6894,6 +6894,11 @@ type Project {
"""
iid
:
String
"""
Search
criteria
for
filtering
alerts
.
This
will
search
on
title
,
description
,
service
,
monitoring_tool
.
"""
search
:
String
"""
Sort
alerts
by
this
criteria
"""
...
...
@@ -6934,6 +6939,11 @@ type Project {
"""
last
:
Int
"""
Search
criteria
for
filtering
alerts
.
This
will
search
on
title
,
description
,
service
,
monitoring_tool
.
"""
search
:
String
"""
Sort
alerts
by
this
criteria
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
45c09e5d
...
...
@@ -20655,6 +20655,16 @@
"ofType"
:
null
},
"defaultValue"
:
null
},
{
"name"
:
"search"
,
"description"
:
"Search criteria for filtering alerts. This will search on title, description, service, monitoring_tool."
,
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"String"
,
"ofType"
:
null
},
"defaultValue"
:
null
}
],
"type"
:
{
...
...
@@ -20707,6 +20717,16 @@
},
"defaultValue"
:
null
},
{
"name"
:
"search"
,
"description"
:
"Search criteria for filtering alerts. This will search on title, description, service, monitoring_tool."
,
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"String"
,
"ofType"
:
null
},
"defaultValue"
:
null
},
{
"name"
:
"after"
,
"description"
:
"Returns the elements in the list that come after the specified cursor."
,
...
...
spec/requests/api/graphql/project/alert_management/alerts_spec.rb
View file @
45c09e5d
...
...
@@ -10,6 +10,7 @@ describe 'getting Alert Management Alerts' do
let_it_be
(
:alert_1
)
{
create
(
:alert_management_alert
,
:all_fields
,
:resolved
,
project:
project
,
issue:
nil
,
severity: :low
)
}
let_it_be
(
:alert_2
)
{
create
(
:alert_management_alert
,
:all_fields
,
project:
project
,
severity: :critical
,
payload:
payload
)
}
let_it_be
(
:other_project_alert
)
{
create
(
:alert_management_alert
,
:all_fields
)
}
let
(
:params
)
{
{}
}
let
(
:fields
)
do
<<~
QUERY
...
...
@@ -23,7 +24,7 @@ describe 'getting Alert Management Alerts' do
graphql_query_for
(
'project'
,
{
'fullPath'
=>
project
.
full_path
},
query_graphql_field
(
'alertManagementAlerts'
,
{}
,
fields
)
query_graphql_field
(
'alertManagementAlerts'
,
params
,
fields
)
)
end
...
...
@@ -83,13 +84,7 @@ describe 'getting Alert Management Alerts' do
end
context
'with iid given'
do
let
(
:query
)
do
graphql_query_for
(
'project'
,
{
'fullPath'
=>
project
.
full_path
},
query_graphql_field
(
'alertManagementAlerts'
,
{
iid:
alert_1
.
iid
.
to_s
},
fields
)
)
end
let
(
:params
)
{
{
iid:
alert_1
.
iid
.
to_s
}
}
it_behaves_like
'a working graphql query'
...
...
@@ -98,14 +93,6 @@ describe 'getting Alert Management Alerts' do
end
context
'sorting data given'
do
let
(
:query
)
do
graphql_query_for
(
'project'
,
{
'fullPath'
=>
project
.
full_path
},
query_graphql_field
(
'alertManagementAlerts'
,
params
,
fields
)
)
end
let
(
:params
)
{
'sort: SEVERITY_DESC'
}
let
(
:iids
)
{
alerts
.
map
{
|
a
|
a
[
'iid'
]
}
}
...
...
@@ -123,6 +110,21 @@ describe 'getting Alert Management Alerts' do
end
end
end
context
'searching'
do
let
(
:params
)
{
{
search:
alert_1
.
title
}
}
it_behaves_like
'a working graphql query'
it
{
expect
(
alerts
.
size
).
to
eq
(
1
)
}
it
{
expect
(
first_alert
[
'iid'
]).
to
eq
(
alert_1
.
iid
.
to_s
)
}
context
'unknown criteria'
do
let
(
:params
)
{
{
search:
'something random'
}
}
it
{
expect
(
alerts
.
size
).
to
eq
(
0
)
}
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