Commit 5a68e0fb authored by Felipe Artur's avatar Felipe Artur

Expose issue updated by on GraphQL

Add updatedBy field on IssueType
parent 6382d3dc
......@@ -41,6 +41,9 @@ module Types
field :assignees, Types::UserType.connection_type, null: true,
description: 'Assignees of the issue'
field :updated_by, Types::UserType, null: true,
description: 'User that last updated the issue'
field :labels, Types::LabelType.connection_type, null: true,
description: 'Labels of the issue'
field :milestone, Types::MilestoneType, null: true,
......@@ -114,6 +117,10 @@ module Types
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
end
def updated_by
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.updated_by_id).find
end
def milestone
Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, object.milestone_id).find
end
......
---
title: Expose issue updated by on GraphQL
merge_request: 46015
author:
type: added
......@@ -7214,6 +7214,11 @@ type EpicIssue implements CurrentUserTodos & Noteable {
"""
updatedAt: Time!
"""
User that last updated the issue
"""
updatedBy: User
"""
Number of upvotes the issue has received
"""
......@@ -9467,6 +9472,11 @@ type Issue implements CurrentUserTodos & Noteable {
"""
updatedAt: Time!
"""
User that last updated the issue
"""
updatedBy: User
"""
Number of upvotes the issue has received
"""
......
......@@ -19865,6 +19865,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updatedBy",
"description": "User that last updated the issue",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "User",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "upvotes",
"description": "Number of upvotes the issue has received",
......@@ -25765,6 +25779,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updatedBy",
"description": "User that last updated the issue",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "User",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "upvotes",
"description": "Number of upvotes the issue has received",
......@@ -1149,6 +1149,7 @@ Relationship between an epic and an issue.
| `totalTimeSpent` | Int! | Total time reported as spent on the issue |
| `type` | IssueType | Type of the issue |
| `updatedAt` | Time! | Timestamp of when the issue was last updated |
| `updatedBy` | User | User that last updated the issue |
| `upvotes` | Int! | Number of upvotes the issue has received |
| `userNotesCount` | Int! | Number of user notes of the issue |
| `userPermissions` | IssuePermissions! | Permissions for the current user on the resource |
......@@ -1342,6 +1343,7 @@ Represents a recorded measurement (object count) for the Admins.
| `totalTimeSpent` | Int! | Total time reported as spent on the issue |
| `type` | IssueType | Type of the issue |
| `updatedAt` | Time! | Timestamp of when the issue was last updated |
| `updatedBy` | User | User that last updated the issue |
| `upvotes` | Int! | Number of upvotes the issue has received |
| `userNotesCount` | Int! | Number of user notes of the issue |
| `userPermissions` | IssuePermissions! | Permissions for the current user on the resource |
......
......@@ -14,7 +14,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
specify { expect(described_class.interfaces).to include(Types::CurrentUserTodos) }
it 'has specific fields' do
fields = %i[id iid title description state reference author assignees participants labels milestone due_date
fields = %i[id iid title description state reference author assignees updated_by participants labels milestone due_date
confidential discussion_locked upvotes downvotes user_notes_count web_path web_url relative_position
subscribed time_estimate total_time_spent human_time_estimate human_total_time_spent closed_at created_at updated_at task_completion_status
designs design_collection alert_management_alert severity current_user_todos]
......
......@@ -71,14 +71,15 @@ RSpec.describe 'Query.issue(id)' do
end
context 'selecting multiple fields' do
let(:issue_fields) { %w(title description) }
let(:issue_fields) { ['title', 'description', 'updatedBy { username }'] }
it 'returns the Issue with the specified fields' do
post_graphql(query, current_user: current_user)
expect(issue_data.keys).to eq( %w(title description) )
expect(issue_data.keys).to eq( %w(title description updatedBy) )
expect(issue_data['title']).to eq(issue.title)
expect(issue_data['description']).to eq(issue.description)
expect(issue_data['updatedBy']['username']).to eq(issue.author.username)
end
end
......
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