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
f5020023
Commit
f5020023
authored
Jun 04, 2020
by
Kirstie Cook
Committed by
Bob Van Landuyt
Jun 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add delete action for annotations in graphql
Update graphql schema
parent
f77c146d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
291 additions
and
0 deletions
+291
-0
app/graphql/mutations/metrics/dashboard/annotations/base.rb
app/graphql/mutations/metrics/dashboard/annotations/base.rb
+18
-0
app/graphql/mutations/metrics/dashboard/annotations/delete.rb
...graphql/mutations/metrics/dashboard/annotations/delete.rb
+32
-0
app/graphql/types/mutation_type.rb
app/graphql/types/mutation_type.rb
+1
-0
changelogs/unreleased/211461-destroy-annotations-graphql-endpoint.yml
...nreleased/211461-destroy-annotations-graphql-endpoint.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+31
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+115
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+9
-0
spec/requests/api/graphql/mutations/metrics/dashboard/annotations/delete_spec.rb
...ql/mutations/metrics/dashboard/annotations/delete_spec.rb
+80
-0
No files found.
app/graphql/mutations/metrics/dashboard/annotations/base.rb
0 → 100644
View file @
f5020023
# frozen_string_literal: true
module
Mutations
module
Metrics
module
Dashboard
module
Annotations
class
Base
<
BaseMutation
private
# This method is defined here in order to be used by `authorized_find!` in the subclasses.
def
find_object
(
id
:)
GitlabSchema
.
object_from_id
(
id
)
end
end
end
end
end
end
app/graphql/mutations/metrics/dashboard/annotations/delete.rb
0 → 100644
View file @
f5020023
# frozen_string_literal: true
module
Mutations
module
Metrics
module
Dashboard
module
Annotations
class
Delete
<
Base
graphql_name
'DeleteAnnotation'
authorize
:delete_metrics_dashboard_annotation
argument
:id
,
GraphQL
::
ID_TYPE
,
required:
true
,
description:
'The global id of the annotation to delete'
def
resolve
(
id
:)
annotation
=
authorized_find!
(
id:
id
)
result
=
::
Metrics
::
Dashboard
::
Annotations
::
DeleteService
.
new
(
context
[
:current_user
],
annotation
).
execute
errors
=
Array
.
wrap
(
result
[
:message
])
{
errors:
errors
}
end
end
end
end
end
end
app/graphql/types/mutation_type.rb
View file @
f5020023
...
@@ -26,6 +26,7 @@ module Types
...
@@ -26,6 +26,7 @@ module Types
mount_mutation
Mutations
::
MergeRequests
::
SetWip
,
calls_gitaly:
true
mount_mutation
Mutations
::
MergeRequests
::
SetWip
,
calls_gitaly:
true
mount_mutation
Mutations
::
MergeRequests
::
SetAssignees
mount_mutation
Mutations
::
MergeRequests
::
SetAssignees
mount_mutation
Mutations
::
Metrics
::
Dashboard
::
Annotations
::
Create
mount_mutation
Mutations
::
Metrics
::
Dashboard
::
Annotations
::
Create
mount_mutation
Mutations
::
Metrics
::
Dashboard
::
Annotations
::
Delete
mount_mutation
Mutations
::
Notes
::
Create
::
Note
,
calls_gitaly:
true
mount_mutation
Mutations
::
Notes
::
Create
::
Note
,
calls_gitaly:
true
mount_mutation
Mutations
::
Notes
::
Create
::
DiffNote
,
calls_gitaly:
true
mount_mutation
Mutations
::
Notes
::
Create
::
DiffNote
,
calls_gitaly:
true
mount_mutation
Mutations
::
Notes
::
Create
::
ImageDiffNote
,
calls_gitaly:
true
mount_mutation
Mutations
::
Notes
::
Create
::
ImageDiffNote
,
calls_gitaly:
true
...
...
changelogs/unreleased/211461-destroy-annotations-graphql-endpoint.yml
0 → 100644
View file @
f5020023
---
title
:
Added delete action for Dashboard Annotations in GraphQL
merge_request
:
33468
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
f5020023
...
@@ -1725,6 +1725,36 @@ type CreateSnippetPayload {
...
@@ -1725,6 +1725,36 @@ type CreateSnippetPayload {
snippet
:
Snippet
snippet
:
Snippet
}
}
"""
Autogenerated input type of DeleteAnnotation
"""
input
DeleteAnnotationInput
{
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
The
global
id
of
the
annotation
to
delete
"""
id
:
ID
!
}
"""
Autogenerated return type of DeleteAnnotation
"""
type
DeleteAnnotationPayload
{
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
Errors
encountered
during
execution
of
the
mutation
.
"""
errors
:
[
String
!]!
}
"""
"""
The response from the AdminSidekiqQueuesDeleteJobs mutation.
The response from the AdminSidekiqQueuesDeleteJobs mutation.
"""
"""
...
@@ -7210,6 +7240,7 @@ type Mutation {
...
@@ -7210,6 +7240,7 @@ type Mutation {
createNote
(
input
:
CreateNoteInput
!):
CreateNotePayload
createNote
(
input
:
CreateNoteInput
!):
CreateNotePayload
createRequirement
(
input
:
CreateRequirementInput
!):
CreateRequirementPayload
createRequirement
(
input
:
CreateRequirementInput
!):
CreateRequirementPayload
createSnippet
(
input
:
CreateSnippetInput
!):
CreateSnippetPayload
createSnippet
(
input
:
CreateSnippetInput
!):
CreateSnippetPayload
deleteAnnotation
(
input
:
DeleteAnnotationInput
!):
DeleteAnnotationPayload
designManagementDelete
(
input
:
DesignManagementDeleteInput
!):
DesignManagementDeletePayload
designManagementDelete
(
input
:
DesignManagementDeleteInput
!):
DesignManagementDeletePayload
designManagementUpload
(
input
:
DesignManagementUploadInput
!):
DesignManagementUploadPayload
designManagementUpload
(
input
:
DesignManagementUploadInput
!):
DesignManagementUploadPayload
destroyNote
(
input
:
DestroyNoteInput
!):
DestroyNotePayload
destroyNote
(
input
:
DestroyNoteInput
!):
DestroyNotePayload
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
f5020023
...
@@ -4570,6 +4570,94 @@
...
@@ -4570,6 +4570,94 @@
"enumValues": null,
"enumValues": null,
"possibleTypes": null
"possibleTypes": null
},
},
{
"kind": "INPUT_OBJECT",
"name": "DeleteAnnotationInput",
"description": "Autogenerated input type of DeleteAnnotation",
"fields": null,
"inputFields": [
{
"name": "id",
"description": "The global id of the annotation to delete",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "DeleteAnnotationPayload",
"description": "Autogenerated return type of DeleteAnnotation",
"fields": [
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "errors",
"description": "Errors encountered during execution of the mutation.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
{
"kind": "OBJECT",
"kind": "OBJECT",
"name": "DeleteJobsResponse",
"name": "DeleteJobsResponse",
...
@@ -20521,6 +20609,33 @@
...
@@ -20521,6 +20609,33 @@
"isDeprecated": false,
"isDeprecated": false,
"deprecationReason": null
"deprecationReason": null
},
},
{
"name": "deleteAnnotation",
"description": null,
"args": [
{
"name": "input",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "DeleteAnnotationInput",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "DeleteAnnotationPayload",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
{
"name": "designManagementDelete",
"name": "designManagementDelete",
"description": null,
"description": null,
doc/api/graphql/reference/index.md
View file @
f5020023
...
@@ -305,6 +305,15 @@ Autogenerated return type of CreateSnippet
...
@@ -305,6 +305,15 @@ Autogenerated return type of CreateSnippet
|
`errors`
| String! => Array | Errors encountered during execution of the mutation. |
|
`errors`
| String! => Array | Errors encountered during execution of the mutation. |
|
`snippet`
| Snippet | The snippet after mutation |
|
`snippet`
| Snippet | The snippet after mutation |
## DeleteAnnotationPayload
Autogenerated return type of DeleteAnnotation
| Name | Type | Description |
| --- | ---- | ---------- |
|
`clientMutationId`
| String | A unique identifier for the client performing the mutation. |
|
`errors`
| String! => Array | Errors encountered during execution of the mutation. |
## DeleteJobsResponse
## DeleteJobsResponse
The response from the AdminSidekiqQueuesDeleteJobs mutation.
The response from the AdminSidekiqQueuesDeleteJobs mutation.
...
...
spec/requests/api/graphql/mutations/metrics/dashboard/annotations/delete_spec.rb
0 → 100644
View file @
f5020023
# frozen_string_literal: true
require
'spec_helper'
describe
Mutations
::
Metrics
::
Dashboard
::
Annotations
::
Delete
do
include
GraphqlHelpers
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:private
,
:repository
)
}
let_it_be
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let_it_be
(
:annotation
)
{
create
(
:metrics_dashboard_annotation
,
environment:
environment
)
}
let
(
:mutation
)
do
variables
=
{
id:
GitlabSchema
.
id_from_object
(
annotation
).
to_s
}
graphql_mutation
(
:delete_annotation
,
variables
)
end
def
mutation_response
graphql_mutation_response
(
:delete_annotation
)
end
specify
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:delete_metrics_dashboard_annotation
)
}
context
'when the user has permission to delete the annotation'
do
before
do
project
.
add_developer
(
current_user
)
end
context
'with valid params'
do
it
'deletes the annotation'
do
expect
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
end
.
to
change
{
Metrics
::
Dashboard
::
Annotation
.
count
}.
by
(
-
1
)
end
end
context
'with invalid params'
do
let
(
:mutation
)
do
variables
=
{
id:
'invalid_id'
}
graphql_mutation
(
:delete_annotation
,
variables
)
end
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
'invalid_id is not a valid GitLab id.'
]
end
context
'when the delete fails'
do
let
(
:service_response
)
{
{
message:
'Annotation has not been deleted'
,
status: :error
,
last_step: :delete
}
}
before
do
allow_next_instance_of
(
Metrics
::
Dashboard
::
Annotations
::
DeleteService
)
do
|
delete_service
|
allow
(
delete_service
).
to
receive
(
:execute
).
and_return
(
service_response
)
end
end
it
'returns the error'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'errors'
]).
to
eq
([
service_response
[
:message
]])
end
end
end
context
'when the user does not have permission to delete the annotation'
do
before
do
project
.
add_reporter
(
current_user
)
end
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
Gitlab
::
Graphql
::
Authorize
::
AuthorizeResource
::
RESOURCE_ACCESS_ERROR
]
it
'does not delete the annotation'
do
expect
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
end
.
not_to
change
{
Metrics
::
Dashboard
::
Annotation
.
count
}
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