Commit 453be557 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'issue_233479-add_updated_by_for_issue_type' into 'master'

Expose issue updated by on GraphQL

See merge request gitlab-org/gitlab!46015
parents 5d61f9af 5a68e0fb
...@@ -41,6 +41,9 @@ module Types ...@@ -41,6 +41,9 @@ module Types
field :assignees, Types::UserType.connection_type, null: true, field :assignees, Types::UserType.connection_type, null: true,
description: 'Assignees of the issue' 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, field :labels, Types::LabelType.connection_type, null: true,
description: 'Labels of the issue' description: 'Labels of the issue'
field :milestone, Types::MilestoneType, null: true, field :milestone, Types::MilestoneType, null: true,
...@@ -114,6 +117,10 @@ module Types ...@@ -114,6 +117,10 @@ module Types
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
end end
def updated_by
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.updated_by_id).find
end
def milestone def milestone
Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, object.milestone_id).find Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, object.milestone_id).find
end end
......
---
title: Expose issue updated by on GraphQL
merge_request: 46015
author:
type: added
...@@ -7214,6 +7214,11 @@ type EpicIssue implements CurrentUserTodos & Noteable { ...@@ -7214,6 +7214,11 @@ type EpicIssue implements CurrentUserTodos & Noteable {
""" """
updatedAt: Time! updatedAt: Time!
"""
User that last updated the issue
"""
updatedBy: User
""" """
Number of upvotes the issue has received Number of upvotes the issue has received
""" """
...@@ -9467,6 +9472,11 @@ type Issue implements CurrentUserTodos & Noteable { ...@@ -9467,6 +9472,11 @@ type Issue implements CurrentUserTodos & Noteable {
""" """
updatedAt: Time! updatedAt: Time!
"""
User that last updated the issue
"""
updatedBy: User
""" """
Number of upvotes the issue has received Number of upvotes the issue has received
""" """
......
...@@ -19865,6 +19865,20 @@ ...@@ -19865,6 +19865,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "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", "name": "upvotes",
"description": "Number of upvotes the issue has received", "description": "Number of upvotes the issue has received",
...@@ -25765,6 +25779,20 @@ ...@@ -25765,6 +25779,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "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", "name": "upvotes",
"description": "Number of upvotes the issue has received", "description": "Number of upvotes the issue has received",
...@@ -1149,6 +1149,7 @@ Relationship between an epic and an issue. ...@@ -1149,6 +1149,7 @@ Relationship between an epic and an issue.
| `totalTimeSpent` | Int! | Total time reported as spent on the issue | | `totalTimeSpent` | Int! | Total time reported as spent on the issue |
| `type` | IssueType | Type of the issue | | `type` | IssueType | Type of the issue |
| `updatedAt` | Time! | Timestamp of when the issue was last updated | | `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 | | `upvotes` | Int! | Number of upvotes the issue has received |
| `userNotesCount` | Int! | Number of user notes of the issue | | `userNotesCount` | Int! | Number of user notes of the issue |
| `userPermissions` | IssuePermissions! | Permissions for the current user on the resource | | `userPermissions` | IssuePermissions! | Permissions for the current user on the resource |
...@@ -1342,6 +1343,7 @@ Represents a recorded measurement (object count) for the Admins. ...@@ -1342,6 +1343,7 @@ Represents a recorded measurement (object count) for the Admins.
| `totalTimeSpent` | Int! | Total time reported as spent on the issue | | `totalTimeSpent` | Int! | Total time reported as spent on the issue |
| `type` | IssueType | Type of the issue | | `type` | IssueType | Type of the issue |
| `updatedAt` | Time! | Timestamp of when the issue was last updated | | `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 | | `upvotes` | Int! | Number of upvotes the issue has received |
| `userNotesCount` | Int! | Number of user notes of the issue | | `userNotesCount` | Int! | Number of user notes of the issue |
| `userPermissions` | IssuePermissions! | Permissions for the current user on the resource | | `userPermissions` | IssuePermissions! | Permissions for the current user on the resource |
......
...@@ -14,7 +14,7 @@ RSpec.describe GitlabSchema.types['Issue'] do ...@@ -14,7 +14,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
specify { expect(described_class.interfaces).to include(Types::CurrentUserTodos) } specify { expect(described_class.interfaces).to include(Types::CurrentUserTodos) }
it 'has specific fields' do 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 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 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] designs design_collection alert_management_alert severity current_user_todos]
......
...@@ -71,14 +71,15 @@ RSpec.describe 'Query.issue(id)' do ...@@ -71,14 +71,15 @@ RSpec.describe 'Query.issue(id)' do
end end
context 'selecting multiple fields' do 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 it 'returns the Issue with the specified fields' do
post_graphql(query, current_user: current_user) 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['title']).to eq(issue.title)
expect(issue_data['description']).to eq(issue.description) expect(issue_data['description']).to eq(issue.description)
expect(issue_data['updatedBy']['username']).to eq(issue.author.username)
end end
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