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
description: 'Stages of the pipeline',
extras: [:lookahead],
resolver: Resolvers::Ci::PipelineStagesResolver
# TODO: Add triggering user as a type
field :user, Types::UserType, null: true,
description: 'Pipeline user',
resolve: -> (pipeline, _args, _context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, pipeline.user_id).find }
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
description: 'Human-readable name of the user'
field :state, Types::UserStateEnum, null: false,
description: 'State of the user'
field :email, GraphQL::STRING_TYPE, null: true,
description: 'User email'
field :avatar_url, GraphQL::STRING_TYPE, null: true,
description: "URL of the user's avatar"
field :web_url, GraphQL::STRING_TYPE, null: false,
......@@ -30,6 +32,8 @@ module Types
field :group_memberships, Types::GroupMemberType.connection_type, null: true,
description: 'Group memberships of the user',
method: :group_members
field :status, Types::UserStatusType, null: true,
description: 'User status'
field :project_memberships, Types::ProjectMemberType.connection_type, null: true,
description: 'Project memberships of the user',
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 {
"""
updatedAt: Time!
"""
Pipeline user
"""
user: User
"""
Permissions for the current user on the resource
"""
......@@ -16462,6 +16467,11 @@ type User {
"""
avatarUrl: String
"""
User email
"""
email: String
"""
Group memberships of the user
"""
......@@ -16567,6 +16577,11 @@ type User {
"""
state: UserState!
"""
User status
"""
status: UserStatus
"""
Todos of the user
"""
......@@ -16705,6 +16720,23 @@ enum UserState {
deactivated
}
type UserStatus {
"""
String representation of emoji
"""
emoji: String
"""
User status message
"""
message: String
"""
HTML of the user status message
"""
messageHtml: String
}
enum VisibilityLevelsEnum {
internal
private
......
......@@ -31145,6 +31145,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "user",
"description": "Pipeline user",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "User",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "userPermissions",
"description": "Permissions for the current user on the resource",
......@@ -48275,6 +48289,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "email",
"description": "User email",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "groupMemberships",
"description": "Group memberships of the user",
......@@ -48526,6 +48554,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "status",
"description": "User status",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "UserStatus",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "todos",
"description": "Todos of the user",
......@@ -48943,6 +48985,61 @@
],
"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",
"name": "VisibilityLevelsEnum",
......@@ -1604,6 +1604,7 @@ Information about pagination in a connection.
| `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) |
| `updatedAt` | Time! | Timestamp of the pipeline's last activity |
| `user` | User | Pipeline user |
| `userPermissions` | PipelinePermissions! | Permissions for the current user on the resource |
## PipelinePermissions
......@@ -2434,9 +2435,11 @@ Autogenerated return type of UpdateSnippet
| Name | Type | Description |
| --- | ---- | ---------- |
| `avatarUrl` | String | URL of the user's avatar |
| `email` | String | User email |
| `id` | ID! | ID of the user |
| `name` | String! | Human-readable name of the user |
| `state` | UserState! | State of the user |
| `status` | UserStatus | User status |
| `userPermissions` | UserPermissions! | Permissions for the current user on the resource |
| `username` | String! | Username of the user. Unique within this instance of GitLab |
| `webPath` | String! | Web path of the user |
......@@ -2448,6 +2451,14 @@ Autogenerated return type of UpdateSnippet
| --- | ---- | ---------- |
| `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
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
snippets
name
username
email
avatarUrl
webUrl
webPath
todos
state
status
authoredMergeRequests
assignedMergeRequests
groupMemberships
......
......@@ -75,7 +75,9 @@ RSpec.describe 'getting user information' do
'name' => presenter.name,
'username' => presenter.username,
'webUrl' => presenter.web_url,
'avatarUrl' => presenter.avatar_url
'avatarUrl' => presenter.avatar_url,
'status' => presenter.status,
'email' => presenter.email
))
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