Commit e226b06b authored by Brett Walker's avatar Brett Walker

Add up/down votes for GraphQL epic query

and changelog
parent 63534f6e
---
title: Add upvote/downvotes attributes to GraphQL Epic query
merge_request: 14311
author:
type: added
...@@ -1230,6 +1230,11 @@ type Epic implements Noteable { ...@@ -1230,6 +1230,11 @@ type Epic implements Noteable {
""" """
last: Int last: Int
): DiscussionConnection! ): DiscussionConnection!
"""
Number of downvotes the epic has received
"""
downvotes: Int!
dueDate: Time dueDate: Time
dueDateFixed: Time dueDateFixed: Time
dueDateFromMilestones: Time dueDateFromMilestones: Time
...@@ -1360,6 +1365,11 @@ type Epic implements Noteable { ...@@ -1360,6 +1365,11 @@ type Epic implements Noteable {
title: String title: String
updatedAt: Time updatedAt: Time
"""
Number of upvotes the epic has received
"""
upvotes: Int!
""" """
Permissions for the current user on the resource Permissions for the current user on the resource
""" """
......
...@@ -3603,6 +3603,24 @@ ...@@ -3603,6 +3603,24 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "downvotes",
"description": "Number of downvotes the epic has received",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "dueDate", "name": "dueDate",
"description": null, "description": null,
...@@ -4154,6 +4172,24 @@ ...@@ -4154,6 +4172,24 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "upvotes",
"description": "Number of upvotes the epic has received",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "userPermissions", "name": "userPermissions",
"description": "Permissions for the current user on the resource", "description": "Permissions for the current user on the resource",
......
...@@ -211,6 +211,8 @@ The API can be explored interactively using the [GraphiQL IDE](../index.md#graph ...@@ -211,6 +211,8 @@ The API can be explored interactively using the [GraphiQL IDE](../index.md#graph
| `dueDateIsFixed` | Boolean | | | `dueDateIsFixed` | Boolean | |
| `dueDateFixed` | Time | | | `dueDateFixed` | Time | |
| `dueDateFromMilestones` | Time | | | `dueDateFromMilestones` | Time | |
| `upvotes` | Int! | Number of upvotes the epic has received |
| `downvotes` | Int! | Number of downvotes the epic has received |
| `closedAt` | Time | | | `closedAt` | Time | |
| `createdAt` | Time | | | `createdAt` | Time | |
| `updatedAt` | Time | | | `updatedAt` | Time | |
......
...@@ -38,6 +38,9 @@ module Types ...@@ -38,6 +38,9 @@ module Types
field :due_date_fixed, Types::TimeType, null: true, authorize: :admin_epic # rubocop:disable Graphql/Descriptions field :due_date_fixed, Types::TimeType, null: true, authorize: :admin_epic # rubocop:disable Graphql/Descriptions
field :due_date_from_milestones, Types::TimeType, null: true, authorize: :admin_epic # rubocop:disable Graphql/Descriptions field :due_date_from_milestones, Types::TimeType, null: true, authorize: :admin_epic # rubocop:disable Graphql/Descriptions
field :upvotes, GraphQL::INT_TYPE, null: false, description: 'Number of upvotes the epic has received'
field :downvotes, GraphQL::INT_TYPE, null: false, description: 'Number of downvotes the epic has received'
field :closed_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions field :closed_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :created_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions field :created_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :updated_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions field :updated_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
......
...@@ -11,7 +11,7 @@ describe GitlabSchema.types['Epic'] do ...@@ -11,7 +11,7 @@ describe GitlabSchema.types['Epic'] do
closed_at created_at updated_at children has_children has_issues closed_at created_at updated_at children has_children has_issues
web_path web_url relation_path reference issues user_permissions web_path web_url relation_path reference issues user_permissions
notes discussions relative_position subscribed participants notes discussions relative_position subscribed participants
descendant_counts descendant_counts upvotes downvotes
] ]
end end
......
...@@ -24,6 +24,8 @@ describe 'Epics through GroupQuery' do ...@@ -24,6 +24,8 @@ describe 'Epics through GroupQuery' do
id id
iid iid
title title
upvotes
downvotes
userPermissions { userPermissions {
adminEpic adminEpic
} }
...@@ -70,6 +72,18 @@ describe 'Epics through GroupQuery' do ...@@ -70,6 +72,18 @@ describe 'Epics through GroupQuery' do
expect_array_response([epic2.to_global_id.to_s, epic.to_global_id.to_s]) expect_array_response([epic2.to_global_id.to_s, epic.to_global_id.to_s])
end end
it 'has upvote/downvote information' do
create(:award_emoji, name: 'thumbsup', awardable: epic, user: user )
create(:award_emoji, name: 'thumbsdown', awardable: epic2, user: user )
post_graphql(query, current_user: user)
expect(epic_node_array).to contain_exactly(
a_hash_including('upvotes' => 1, 'downvotes' => 0),
a_hash_including('upvotes' => 0, 'downvotes' => 1)
)
end
describe 'can admin epics' do describe 'can admin epics' do
context 'when permission is absent' do context 'when permission is absent' do
it 'returns false for adminEpic' do it 'returns false for adminEpic' 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