Commit 5eae152e authored by Nick Thomas's avatar Nick Thomas

Merge branch...

Merge branch '11506-add-additional-attributes-and-arguments-for-the-graphql-epic-query' into 'master'

GraphQL: Add upvotes and downvotes to epic query

See merge request gitlab-org/gitlab!14311
parents b32e287d e226b06b
---
title: Add upvote/downvotes attributes to GraphQL Epic query
merge_request: 14311
author:
type: added
......@@ -1230,6 +1230,11 @@ type Epic implements Noteable {
"""
last: Int
): DiscussionConnection!
"""
Number of downvotes the epic has received
"""
downvotes: Int!
dueDate: Time
dueDateFixed: Time
dueDateFromMilestones: Time
......@@ -1360,6 +1365,11 @@ type Epic implements Noteable {
title: String
updatedAt: Time
"""
Number of upvotes the epic has received
"""
upvotes: Int!
"""
Permissions for the current user on the resource
"""
......
......@@ -3630,6 +3630,24 @@
"isDeprecated": false,
"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",
"description": null,
......@@ -4181,6 +4199,24 @@
"isDeprecated": false,
"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",
"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
| `dueDateIsFixed` | Boolean | |
| `dueDateFixed` | Time | |
| `dueDateFromMilestones` | Time | |
| `upvotes` | Int! | Number of upvotes the epic has received |
| `downvotes` | Int! | Number of downvotes the epic has received |
| `closedAt` | Time | |
| `createdAt` | Time | |
| `updatedAt` | Time | |
......
......@@ -38,6 +38,9 @@ module Types
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 :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 :created_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
closed_at created_at updated_at children has_children has_issues
web_path web_url relation_path reference issues user_permissions
notes discussions relative_position subscribed participants
descendant_counts
descendant_counts upvotes downvotes
]
end
......
......@@ -24,6 +24,8 @@ describe 'Epics through GroupQuery' do
id
iid
title
upvotes
downvotes
userPermissions {
adminEpic
}
......@@ -70,6 +72,18 @@ describe 'Epics through GroupQuery' do
expect_array_response([epic2.to_global_id.to_s, epic.to_global_id.to_s])
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
context 'when permission is absent' 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