Commit 28462a20 authored by Jarka Košanová's avatar Jarka Košanová

Manage and display labels from epic graphql

- add labels to epic_type
- Add and remove labels from UpdateEpic mutation
parent de65cca0
---
title: Manage and display labels from epic in the GraphQL API
merge_request: 19642
author:
type: added
......@@ -216,6 +216,11 @@ type CreateDiffNotePayload {
Autogenerated input type of CreateEpic
"""
input CreateEpicInput {
"""
The IDs of labels to be added to the epic.
"""
addLabelIds: [ID!]
"""
A unique identifier for the client performing the mutation.
"""
......@@ -241,6 +246,11 @@ input CreateEpicInput {
"""
groupPath: ID!
"""
The IDs of labels to be removed from the epic.
"""
removeLabelIds: [ID!]
"""
The start date of the epic
"""
......@@ -1171,6 +1181,31 @@ type Epic implements Noteable {
last: Int
): EpicIssueConnection
"""
Labels assigned to the epic
"""
labels(
"""
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
): LabelConnection
"""
All notes on this noteable
"""
......@@ -5025,6 +5060,11 @@ type TreeEntryEdge {
Autogenerated input type of UpdateEpic
"""
input UpdateEpicInput {
"""
The IDs of labels to be added to the epic.
"""
addLabelIds: [ID!]
"""
A unique identifier for the client performing the mutation.
"""
......@@ -5055,6 +5095,11 @@ input UpdateEpicInput {
"""
iid: String!
"""
The IDs of labels to be removed from the epic.
"""
removeLabelIds: [ID!]
"""
The start date of the epic
"""
......
......@@ -3788,6 +3788,59 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "labels",
"description": "Labels assigned to the epic",
"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": "OBJECT",
"name": "LabelConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "notes",
"description": "All notes on this noteable",
......@@ -6251,8 +6304,8 @@
},
{
"kind": "OBJECT",
"name": "UserConnection",
"description": "The connection type for User.",
"name": "LabelConnection",
"description": "The connection type for Label.",
"fields": [
{
"name": "edges",
......@@ -6265,7 +6318,7 @@
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "UserEdge",
"name": "LabelEdge",
"ofType": null
}
},
......@@ -6283,7 +6336,7 @@
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "User",
"name": "Label",
"ofType": null
}
},
......@@ -6318,7 +6371,7 @@
},
{
"kind": "OBJECT",
"name": "UserEdge",
"name": "LabelEdge",
"description": "An edge in a connection.",
"fields": [
{
......@@ -6347,7 +6400,7 @@
],
"type": {
"kind": "OBJECT",
"name": "User",
"name": "Label",
"ofType": null
},
"isDeprecated": false,
......@@ -6363,8 +6416,103 @@
},
{
"kind": "OBJECT",
"name": "EpicIssueConnection",
"description": "The connection type for EpicIssue.",
"name": "Label",
"description": null,
"fields": [
{
"name": "color",
"description": "Background color of the label",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "description",
"description": "Description of the label (markdown rendered as HTML for caching)",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "descriptionHtml",
"description": "The GitLab Flavored Markdown rendering of `description`",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "textColor",
"description": "Text color of the label",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "title",
"description": "Content of the label",
"args": [
],
"type": {
"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",
"name": "UserConnection",
"description": "The connection type for User.",
"fields": [
{
"name": "edges",
......@@ -6377,7 +6525,7 @@
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "EpicIssueEdge",
"name": "UserEdge",
"ofType": null
}
},
......@@ -6395,7 +6543,7 @@
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "EpicIssue",
"name": "User",
"ofType": null
}
},
......@@ -6430,7 +6578,7 @@
},
{
"kind": "OBJECT",
"name": "EpicIssueEdge",
"name": "UserEdge",
"description": "An edge in a connection.",
"fields": [
{
......@@ -6459,7 +6607,7 @@
],
"type": {
"kind": "OBJECT",
"name": "EpicIssue",
"name": "User",
"ofType": null
},
"isDeprecated": false,
......@@ -6475,74 +6623,21 @@
},
{
"kind": "OBJECT",
"name": "EpicIssue",
"description": null,
"name": "EpicIssueConnection",
"description": "The connection type for EpicIssue.",
"fields": [
{
"name": "assignees",
"description": "Assignees of the issue",
"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": "OBJECT",
"name": "UserConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "author",
"description": "User that created the issue",
"name": "edges",
"description": "A list of edges.",
"args": [
],
"type": {
"kind": "NON_NULL",
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "User",
"name": "EpicIssueEdge",
"ofType": null
}
},
......@@ -6550,22 +6645,26 @@
"deprecationReason": null
},
{
"name": "closedAt",
"description": "Timestamp of when the issue was closed",
"name": "nodes",
"description": "A list of nodes.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "EpicIssue",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "confidential",
"description": "Indicates the issue is confidential",
"name": "pageInfo",
"description": "Information to aid in pagination.",
"args": [
],
......@@ -6573,8 +6672,169 @@
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"kind": "OBJECT",
"name": "PageInfo",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "EpicIssueEdge",
"description": "An edge in a connection.",
"fields": [
{
"name": "cursor",
"description": "A cursor for use in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "node",
"description": "The item at the end of the edge.",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "EpicIssue",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "EpicIssue",
"description": null,
"fields": [
{
"name": "assignees",
"description": "Assignees of the issue",
"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": "OBJECT",
"name": "UserConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "author",
"description": "User that created the issue",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "User",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "closedAt",
"description": "Timestamp of when the issue was closed",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "confidential",
"description": "Indicates the issue is confidential",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
......@@ -7211,294 +7471,23 @@
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "userPermissions",
"description": "Permissions for the current user on the resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "IssuePermissions",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "webPath",
"description": "Web path of the issue",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "webUrl",
"description": "Web URL of the issue",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "weight",
"description": null,
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
{
"kind": "INTERFACE",
"name": "Noteable",
"ofType": null
}
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "IssuePermissions",
"description": "Check permissions for the current user on a issue",
"fields": [
{
"name": "adminIssue",
"description": "Whether or not a user can perform `admin_issue` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "createDesign",
"description": "Whether or not a user can perform `create_design` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "createNote",
"description": "Whether or not a user can perform `create_note` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "destroyDesign",
"description": "Whether or not a user can perform `destroy_design` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "readDesign",
"description": "Whether or not a user can perform `read_design` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "readIssue",
"description": "Whether or not a user can perform `read_issue` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "reopenIssue",
"description": "Whether or not a user can perform `reopen_issue` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updateIssue",
"description": "Whether or not a user can perform `update_issue` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "IssueState",
"description": "State of a GitLab issue",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "opened",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "closed",
"description": null,
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "locked",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "LabelConnection",
"description": "The connection type for Label.",
"fields": [
{
"name": "edges",
"description": "A list of edges.",
"name": "userPermissions",
"description": "Permissions for the current user on the resource",
"args": [
],
"type": {
"kind": "LIST",
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "LabelEdge",
"name": "IssuePermissions",
"ofType": null
}
},
......@@ -7506,17 +7495,17 @@
"deprecationReason": null
},
{
"name": "nodes",
"description": "A list of nodes.",
"name": "webPath",
"description": "Web path of the issue",
"args": [
],
"type": {
"kind": "LIST",
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Label",
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
......@@ -7524,8 +7513,8 @@
"deprecationReason": null
},
{
"name": "pageInfo",
"description": "Information to aid in pagination.",
"name": "webUrl",
"description": "Web URL of the issue",
"args": [
],
......@@ -7533,30 +7522,48 @@
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PageInfo",
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "weight",
"description": null,
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
{
"kind": "INTERFACE",
"name": "Noteable",
"ofType": null
}
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "LabelEdge",
"description": "An edge in a connection.",
"name": "IssuePermissions",
"description": "Check permissions for the current user on a issue",
"fields": [
{
"name": "cursor",
"description": "A cursor for use in pagination.",
"name": "adminIssue",
"description": "Whether or not a user can perform `admin_issue` on this resource",
"args": [
],
......@@ -7565,7 +7572,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "Boolean",
"ofType": null
}
},
......@@ -7573,35 +7580,44 @@
"deprecationReason": null
},
{
"name": "node",
"description": "The item at the end of the edge.",
"name": "createDesign",
"description": "Whether or not a user can perform `create_design` on this resource",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "Label",
"ofType": null
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
},
{
"name": "createNote",
"description": "Whether or not a user can perform `create_note` on this resource",
"args": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Label",
"description": null,
"fields": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "color",
"description": "Background color of the label",
"name": "destroyDesign",
"description": "Whether or not a user can perform `destroy_design` on this resource",
"args": [
],
......@@ -7610,7 +7626,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "Boolean",
"ofType": null
}
},
......@@ -7618,36 +7634,44 @@
"deprecationReason": null
},
{
"name": "description",
"description": "Description of the label (markdown rendered as HTML for caching)",
"name": "readDesign",
"description": "Whether or not a user can perform `read_design` on this resource",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "descriptionHtml",
"description": "The GitLab Flavored Markdown rendering of `description`",
"name": "readIssue",
"description": "Whether or not a user can perform `read_issue` on this resource",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "textColor",
"description": "Text color of the label",
"name": "reopenIssue",
"description": "Whether or not a user can perform `reopen_issue` on this resource",
"args": [
],
......@@ -7656,7 +7680,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "Boolean",
"ofType": null
}
},
......@@ -7664,8 +7688,8 @@
"deprecationReason": null
},
{
"name": "title",
"description": "Content of the label",
"name": "updateIssue",
"description": "Whether or not a user can perform `update_issue` on this resource",
"args": [
],
......@@ -7674,7 +7698,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "Boolean",
"ofType": null
}
},
......@@ -7689,6 +7713,35 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "IssueState",
"description": "State of a GitLab issue",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "opened",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "closed",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "locked",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Milestone",
......@@ -16879,6 +16932,42 @@
},
"defaultValue": null
},
{
"name": "addLabelIds",
"description": "The IDs of labels to be added to the epic.",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "removeLabelIds",
"description": "The IDs of labels to be removed from the epic.",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "iid",
"description": "The iid of the epic to mutate",
......@@ -17088,6 +17177,42 @@
},
"defaultValue": null
},
{
"name": "addLabelIds",
"description": "The IDs of labels to be added to the epic.",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "removeLabelIds",
"description": "The IDs of labels to be removed from the epic.",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"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.",
......
......@@ -38,6 +38,14 @@ module Mutations
GraphQL::BOOLEAN_TYPE,
required: false,
description: 'Indicates end date should be sourced from due_date_fixed field not the issue milestones'
argument :add_label_ids,
[GraphQL::ID_TYPE],
required: false,
description: 'The IDs of labels to be added to the epic.'
argument :remove_label_ids,
[GraphQL::ID_TYPE],
required: false,
description: 'The IDs of labels to be removed from the epic.'
end
def validate_arguments!(args)
......
......@@ -46,6 +46,8 @@ module Types
::Types::EpicType.connection_type,
null: true,
resolver: ::Resolvers::EpicResolver
field :labels, Types::LabelType.connection_type, null: true,
description: 'Labels assigned to the epic'
field :has_children, GraphQL::BOOLEAN_TYPE, null: false, method: :has_children? # rubocop:disable Graphql/Descriptions
field :has_issues, GraphQL::BOOLEAN_TYPE, null: false, method: :has_issues? # rubocop:disable Graphql/Descriptions
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
describe GitlabSchema.types['Epic'] do
let(:fields) do
%i[
id iid title description state group parent author
id iid title description state group parent author labels
start_date start_date_is_fixed start_date_fixed start_date_from_milestones
due_date due_date_is_fixed due_date_fixed due_date_from_milestones
closed_at created_at updated_at children has_children has_issues
......
......@@ -7,7 +7,10 @@ describe 'Updating an Epic' do
let_it_be(:current_user) { create(:user) }
let_it_be(:group) { create(:group) }
let(:epic) { create(:epic, group: group, title: 'original title') }
let(:label_1) { create(:group_label, group: group) }
let(:label_2) { create(:group_label, group: group) }
let(:label_3) { create(:group_label, group: group) }
let(:epic) { create(:epic, group: group, title: 'original title', labels: [label_2]) }
let(:attributes) do
{
......@@ -100,6 +103,15 @@ describe 'Updating an Epic' do
end
end
context 'when changing labels of the epic' do
let(:attributes) { { add_label_ids: [label_1.id, label_3.id], remove_label_ids: label_2.id } }
it 'adds and removes labels correctly' do
post_graphql_mutation(mutation, current_user: current_user)
expect(epic.reload.labels).to match_array([label_1, label_3])
end
end
context 'when there are ActiveRecord validation errors' do
let(:attributes) { { title: '' } }
......
......@@ -606,6 +606,24 @@ describe Issues::UpdateService, :mailer do
end
end
context 'when same id is passed as add_label_ids and remove_label_ids' do
let(:params) { { add_label_ids: [label.id], remove_label_ids: [label.id] } }
context 'for a label assigned to an issue' do
it 'removes the label' do
issue.update(labels: [label])
expect(result.label_ids).to be_empty
end
end
context 'for a label not assigned to an issue' do
it 'does not add the label' do
expect(result.label_ids).to be_empty
end
end
end
context 'when duplicate label titles are given' do
let(:params) do
{ labels: [label3.title, label3.title] }
......
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