Commit f52610b6 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch '223814_add_notes_and_discussions_to_vulnerability_type' into 'master'

Add `discussions` and `notes` fields for `VulnerabilityType`

See merge request gitlab-org/gitlab!42892
parents af89cb83 1c54647d
...@@ -8,8 +8,7 @@ module Types ...@@ -8,8 +8,7 @@ module Types
field :notes, Types::Notes::NoteType.connection_type, null: false, description: "All notes on this noteable" field :notes, Types::Notes::NoteType.connection_type, null: false, description: "All notes on this noteable"
field :discussions, Types::Notes::DiscussionType.connection_type, null: false, description: "All discussions on this noteable" field :discussions, Types::Notes::DiscussionType.connection_type, null: false, description: "All discussions on this noteable"
definition_methods do def self.resolve_type(object, context)
def resolve_type(object, context)
case object case object
when Issue when Issue
Types::IssueType Types::IssueType
...@@ -27,5 +26,6 @@ module Types ...@@ -27,5 +26,6 @@ module Types
end end
end end
end end
end
end end
Types::Notes::NoteableType.prepend_if_ee('::EE::Types::Notes::NoteableType')
...@@ -18733,7 +18733,7 @@ type VulnerabilitiesCountByDayEdge { ...@@ -18733,7 +18733,7 @@ type VulnerabilitiesCountByDayEdge {
""" """
Represents a vulnerability Represents a vulnerability
""" """
type Vulnerability { type Vulnerability implements Noteable {
""" """
Description of the vulnerability Description of the vulnerability
""" """
...@@ -18744,6 +18744,31 @@ type Vulnerability { ...@@ -18744,6 +18744,31 @@ type Vulnerability {
""" """
detectedAt: Time! detectedAt: Time!
"""
All discussions on this noteable
"""
discussions(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): DiscussionConnection!
""" """
GraphQL ID of the vulnerability GraphQL ID of the vulnerability
""" """
...@@ -18789,6 +18814,31 @@ type Vulnerability { ...@@ -18789,6 +18814,31 @@ type Vulnerability {
""" """
location: VulnerabilityLocation location: VulnerabilityLocation
"""
All notes on this noteable
"""
notes(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): NoteConnection!
""" """
Primary identifier of the vulnerability. Primary identifier of the vulnerability.
""" """
......
...@@ -33910,6 +33910,11 @@ ...@@ -33910,6 +33910,11 @@
"kind": "OBJECT", "kind": "OBJECT",
"name": "Snippet", "name": "Snippet",
"ofType": null "ofType": null
},
{
"kind": "OBJECT",
"name": "Vulnerability",
"ofType": null
} }
] ]
}, },
...@@ -54817,6 +54822,63 @@ ...@@ -54817,6 +54822,63 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "discussions",
"description": "All discussions on this noteable",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "DiscussionConnection",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "id", "name": "id",
"description": "GraphQL ID of the vulnerability", "description": "GraphQL ID of the vulnerability",
...@@ -54942,6 +55004,63 @@ ...@@ -54942,6 +55004,63 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "notes",
"description": "All notes on this noteable",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "NoteConnection",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "primaryIdentifier", "name": "primaryIdentifier",
"description": "Primary identifier of the vulnerability.", "description": "Primary identifier of the vulnerability.",
...@@ -55111,7 +55230,11 @@ ...@@ -55111,7 +55230,11 @@
], ],
"inputFields": null, "inputFields": null,
"interfaces": [ "interfaces": [
{
"kind": "INTERFACE",
"name": "Noteable",
"ofType": null
}
], ],
"enumValues": null, "enumValues": null,
"possibleTypes": null "possibleTypes": null
# frozen_string_literal: true
module EE
module Types
module Notes
module NoteableType
module ClassMethods
def resolve_type(object, *)
return ::Types::VulnerabilityType if ::Vulnerability === object
super
end
end
def self.prepended(base)
base.singleton_class.prepend(ClassMethods)
end
end
end
end
end
...@@ -5,6 +5,8 @@ module Types ...@@ -5,6 +5,8 @@ module Types
graphql_name 'Vulnerability' graphql_name 'Vulnerability'
description 'Represents a vulnerability' description 'Represents a vulnerability'
implements(Types::Notes::NoteableType)
authorize :read_vulnerability authorize :read_vulnerability
expose_permissions Types::PermissionTypes::Vulnerability expose_permissions Types::PermissionTypes::Vulnerability
......
---
title: Add `discussions` and `notes` fields for VulnerabilityType on GraphQL API
merge_request: 42892
author:
type: added
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe EE::Types::Notes::NoteableType do
let(:extended_class) { Types::Notes::NoteableType }
describe ".resolve_type" do
it 'knows the correct type for objects' do
expect(extended_class.resolve_type(build(:issue), {})).to eq(Types::IssueType)
expect(extended_class.resolve_type(build(:merge_request), {})).to eq(Types::MergeRequestType)
expect(extended_class.resolve_type(build(:design), {})).to eq(Types::DesignManagement::DesignType)
expect(extended_class.resolve_type(build(:alert_management_alert), {})).to eq(Types::AlertManagement::AlertType)
expect(extended_class.resolve_type(build(:vulnerability), {})).to eq(Types::VulnerabilityType)
end
end
end
...@@ -23,7 +23,9 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do ...@@ -23,7 +23,9 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do
identifiers identifiers
project project
issueLinks issueLinks
detected_at] detected_at
notes
discussions]
end end
before do before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment