Commit f0df8e3f authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'lm-add-user-to-pipeline' into 'master'

GraphQL: Add user fields to pipeline

See merge request gitlab-org/gitlab!39402
parents ea698973 9b8b4023
...@@ -45,8 +45,9 @@ module Types ...@@ -45,8 +45,9 @@ module Types
description: 'Stages of the pipeline', description: 'Stages of the pipeline',
extras: [:lookahead], extras: [:lookahead],
resolver: Resolvers::Ci::PipelineStagesResolver resolver: Resolvers::Ci::PipelineStagesResolver
field :user, Types::UserType, null: true,
# TODO: Add triggering user as a type description: 'Pipeline user',
resolve: -> (pipeline, _args, _context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, pipeline.user_id).find }
end end
end end
end end
......
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class UserStatusType < BaseObject
graphql_name 'UserStatus'
markdown_field :message_html, null: true,
description: 'HTML of the user status message'
field :message, GraphQL::STRING_TYPE, null: true,
description: 'User status message'
field :emoji, GraphQL::STRING_TYPE, null: true,
description: 'String representation of emoji'
end
end
...@@ -18,6 +18,8 @@ module Types ...@@ -18,6 +18,8 @@ module Types
description: 'Human-readable name of the user' description: 'Human-readable name of the user'
field :state, Types::UserStateEnum, null: false, field :state, Types::UserStateEnum, null: false,
description: 'State of the user' description: 'State of the user'
field :email, GraphQL::STRING_TYPE, null: true,
description: 'User email'
field :avatar_url, GraphQL::STRING_TYPE, null: true, field :avatar_url, GraphQL::STRING_TYPE, null: true,
description: "URL of the user's avatar" description: "URL of the user's avatar"
field :web_url, GraphQL::STRING_TYPE, null: false, field :web_url, GraphQL::STRING_TYPE, null: false,
...@@ -30,6 +32,8 @@ module Types ...@@ -30,6 +32,8 @@ module Types
field :group_memberships, Types::GroupMemberType.connection_type, null: true, field :group_memberships, Types::GroupMemberType.connection_type, null: true,
description: 'Group memberships of the user', description: 'Group memberships of the user',
method: :group_members method: :group_members
field :status, Types::UserStatusType, null: true,
description: 'User status'
field :project_memberships, Types::ProjectMemberType.connection_type, null: true, field :project_memberships, Types::ProjectMemberType.connection_type, null: true,
description: 'Project memberships of the user', description: 'Project memberships of the user',
method: :project_members method: :project_members
......
---
title: 'GraphQL: Add user to pipeline + status and email to user + StatusType'
merge_request: 39402
author:
type: added
...@@ -10422,6 +10422,11 @@ type Pipeline { ...@@ -10422,6 +10422,11 @@ type Pipeline {
""" """
updatedAt: Time! updatedAt: Time!
"""
Pipeline user
"""
user: User
""" """
Permissions for the current user on the resource Permissions for the current user on the resource
""" """
...@@ -16462,6 +16467,11 @@ type User { ...@@ -16462,6 +16467,11 @@ type User {
""" """
avatarUrl: String avatarUrl: String
"""
User email
"""
email: String
""" """
Group memberships of the user Group memberships of the user
""" """
...@@ -16567,6 +16577,11 @@ type User { ...@@ -16567,6 +16577,11 @@ type User {
""" """
state: UserState! state: UserState!
"""
User status
"""
status: UserStatus
""" """
Todos of the user Todos of the user
""" """
...@@ -16705,6 +16720,23 @@ enum UserState { ...@@ -16705,6 +16720,23 @@ enum UserState {
deactivated deactivated
} }
type UserStatus {
"""
String representation of emoji
"""
emoji: String
"""
User status message
"""
message: String
"""
HTML of the user status message
"""
messageHtml: String
}
enum VisibilityLevelsEnum { enum VisibilityLevelsEnum {
internal internal
private private
......
...@@ -31145,6 +31145,20 @@ ...@@ -31145,6 +31145,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "user",
"description": "Pipeline user",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "User",
"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",
...@@ -48275,6 +48289,20 @@ ...@@ -48275,6 +48289,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "email",
"description": "User email",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "groupMemberships", "name": "groupMemberships",
"description": "Group memberships of the user", "description": "Group memberships of the user",
...@@ -48526,6 +48554,20 @@ ...@@ -48526,6 +48554,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "status",
"description": "User status",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "UserStatus",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "todos", "name": "todos",
"description": "Todos of the user", "description": "Todos of the user",
...@@ -48943,6 +48985,61 @@ ...@@ -48943,6 +48985,61 @@
], ],
"possibleTypes": null "possibleTypes": null
}, },
{
"kind": "OBJECT",
"name": "UserStatus",
"description": null,
"fields": [
{
"name": "emoji",
"description": "String representation of emoji",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "message",
"description": "User status message",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "messageHtml",
"description": "HTML of the user status message",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{ {
"kind": "ENUM", "kind": "ENUM",
"name": "VisibilityLevelsEnum", "name": "VisibilityLevelsEnum",
...@@ -1604,6 +1604,7 @@ Information about pagination in a connection. ...@@ -1604,6 +1604,7 @@ Information about pagination in a connection.
| `startedAt` | Time | Timestamp when the pipeline was started | | `startedAt` | Time | Timestamp when the pipeline was started |
| `status` | PipelineStatusEnum! | Status of the pipeline (CREATED, WAITING_FOR_RESOURCE, PREPARING, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL, SCHEDULED) | | `status` | PipelineStatusEnum! | Status of the pipeline (CREATED, WAITING_FOR_RESOURCE, PREPARING, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL, SCHEDULED) |
| `updatedAt` | Time! | Timestamp of the pipeline's last activity | | `updatedAt` | Time! | Timestamp of the pipeline's last activity |
| `user` | User | Pipeline user |
| `userPermissions` | PipelinePermissions! | Permissions for the current user on the resource | | `userPermissions` | PipelinePermissions! | Permissions for the current user on the resource |
## PipelinePermissions ## PipelinePermissions
...@@ -2434,9 +2435,11 @@ Autogenerated return type of UpdateSnippet ...@@ -2434,9 +2435,11 @@ Autogenerated return type of UpdateSnippet
| Name | Type | Description | | Name | Type | Description |
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `avatarUrl` | String | URL of the user's avatar | | `avatarUrl` | String | URL of the user's avatar |
| `email` | String | User email |
| `id` | ID! | ID of the user | | `id` | ID! | ID of the user |
| `name` | String! | Human-readable name of the user | | `name` | String! | Human-readable name of the user |
| `state` | UserState! | State of the user | | `state` | UserState! | State of the user |
| `status` | UserStatus | User status |
| `userPermissions` | UserPermissions! | Permissions for the current user on the resource | | `userPermissions` | UserPermissions! | Permissions for the current user on the resource |
| `username` | String! | Username of the user. Unique within this instance of GitLab | | `username` | String! | Username of the user. Unique within this instance of GitLab |
| `webPath` | String! | Web path of the user | | `webPath` | String! | Web path of the user |
...@@ -2448,6 +2451,14 @@ Autogenerated return type of UpdateSnippet ...@@ -2448,6 +2451,14 @@ Autogenerated return type of UpdateSnippet
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `createSnippet` | Boolean! | Indicates the user can perform `create_snippet` on this resource | | `createSnippet` | Boolean! | Indicates the user can perform `create_snippet` on this resource |
## UserStatus
| Name | Type | Description |
| --- | ---- | ---------- |
| `emoji` | String | String representation of emoji |
| `message` | String | User status message |
| `messageHtml` | String | HTML of the user status message |
## VulnerabilitiesCountByDay ## VulnerabilitiesCountByDay
Represents the count of vulnerabilities by severity on a particular day Represents the count of vulnerabilities by severity on a particular day
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Types::UserStatusType do
specify { expect(described_class.graphql_name).to eq('UserStatus') }
it 'exposes the expected fields' do
expected_fields = %i[
emoji
message
message_html
]
expect(described_class).to have_graphql_fields(*expected_fields)
end
end
...@@ -14,11 +14,13 @@ RSpec.describe GitlabSchema.types['User'] do ...@@ -14,11 +14,13 @@ RSpec.describe GitlabSchema.types['User'] do
snippets snippets
name name
username username
email
avatarUrl avatarUrl
webUrl webUrl
webPath webPath
todos todos
state state
status
authoredMergeRequests authoredMergeRequests
assignedMergeRequests assignedMergeRequests
groupMemberships groupMemberships
......
...@@ -75,7 +75,9 @@ RSpec.describe 'getting user information' do ...@@ -75,7 +75,9 @@ RSpec.describe 'getting user information' do
'name' => presenter.name, 'name' => presenter.name,
'username' => presenter.username, 'username' => presenter.username,
'webUrl' => presenter.web_url, 'webUrl' => presenter.web_url,
'avatarUrl' => presenter.avatar_url 'avatarUrl' => presenter.avatar_url,
'status' => presenter.status,
'email' => presenter.email
)) ))
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