Commit 99fe571d authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '213401-expose-epic-has-parent' into 'master'

Expose hasParent on epic

See merge request gitlab-org/gitlab!29214
parents a5eb26ff 2a300991
......@@ -2159,6 +2159,11 @@ type Epic implements Noteable {
"""
hasIssues: Boolean!
"""
Indicates if the epic has a parent epic
"""
hasParent: Boolean!
"""
Current health status of the epic
"""
......
......@@ -6336,6 +6336,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "hasParent",
"description": "Indicates if the epic has a parent epic",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "healthStatus",
"description": "Current health status of the epic",
......
......@@ -359,6 +359,7 @@ Represents an epic.
| `group` | Group! | Group to which the epic belongs |
| `hasChildren` | Boolean! | Indicates if the epic has children |
| `hasIssues` | Boolean! | Indicates if the epic has direct issues |
| `hasParent` | Boolean! | Indicates if the epic has a parent epic |
| `healthStatus` | EpicHealthStatus | Current health status of the epic |
| `id` | ID! | ID of the epic |
| `iid` | ID! | Internal ID of the epic |
......
fragment BaseEpic on Epic {
id
iid
title
description
state
webUrl
startDate
dueDate
hasChildren
descendantCounts {
openedEpics
closedEpics
openedIssues
closedIssues
}
group {
name
fullName
}
}
fragment EpicNode on Epic {
...BaseEpic
state
reference(full: true)
createdAt
closedAt
relationPath
createdAt
hasChildren
hasIssues
group {
fullPath
}
}
#import "./epic.fragment.graphql"
query epicChildEpics(
$fullPath: ID!
$iid: ID!
......@@ -12,6 +14,7 @@ query epicChildEpics(
epic(iid: $iid) {
id
title
hasChildren
children(state: $state, sort: $sort, startDate: $startDate, endDate: $dueDate) {
edges {
node {
......@@ -22,6 +25,7 @@ query epicChildEpics(
webUrl
startDate
dueDate
hasChildren
descendantWeightSum {
closedIssues
openedIssues
......@@ -33,21 +37,7 @@ query epicChildEpics(
children {
edges {
node {
id
title
description
state
webUrl
startDate
dueDate
descendantWeightSum {
closedIssues
openedIssues
}
group {
name
fullName
}
...EpicNode
}
}
}
......
#import "./epic.fragment.graphql"
query groupEpics(
$fullPath: ID!
$state: EpicState
......@@ -22,39 +24,11 @@ query groupEpics(
) {
edges {
node {
id
title
description
state
webUrl
startDate
dueDate
descendantWeightSum {
closedIssues
openedIssues
}
group {
name
fullName
}
...BaseEpic
children {
edges {
node {
id
title
description
state
webUrl
startDate
dueDate
descendantWeightSum {
closedIssues
openedIssues
}
group {
name
fullName
}
...EpicNode
}
}
}
......
......@@ -84,6 +84,9 @@ module Types
description: 'Indicates if the epic has children'
field :has_issues, GraphQL::BOOLEAN_TYPE, null: false,
description: 'Indicates if the epic has direct issues'
field :has_parent, GraphQL::BOOLEAN_TYPE, null: false,
method: :has_parent?,
description: 'Indicates if the epic has a parent epic'
field :web_path, GraphQL::STRING_TYPE, null: false,
description: 'Web path of the epic',
......
......@@ -322,6 +322,10 @@ module EE
issues.any?
end
def has_parent?
!!parent_id
end
def child?(id)
children.where(id: id).exists?
end
......
---
title: Expose hasParent GraphQL field on epic
merge_request: 29214
author:
type: added
......@@ -8,7 +8,7 @@ describe GitlabSchema.types['Epic'] do
id iid title description confidential 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
closed_at created_at updated_at children has_children has_issues has_parent
web_path web_url relation_path reference issues user_permissions
notes discussions relative_position subscribed participants
descendant_counts descendant_weight_sum upvotes downvotes health_status
......
......@@ -551,6 +551,20 @@ describe Epic do
end
end
describe '#has_parent?' do
let_it_be(:epic, reload: true) { create(:epic, group: group) }
it 'has no parent' do
expect(epic.has_parent?).to be_falsey
end
it 'has parent' do
create(:epic, group: group, children: [epic])
expect(epic.has_parent?).to be_truthy
end
end
context 'mentioning other objects' do
let(:epic) { create(:epic, group: group) }
......
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