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

Merge branch 'ph/moreMergeRequestGraphqlFields' into 'master'

Added more field types for merge request widget

See merge request gitlab-org/gitlab!48773
parents ae962716 a6ee50ab
......@@ -94,6 +94,9 @@ module Types
field :project, Types::ProjectType, null: true,
description: 'Project the pipeline belongs to'
field :active, GraphQL::BOOLEAN_TYPE, null: false, method: :active?,
description: 'Indicates if the pipeline is active'
def detailed_status
object.detailed_status(context[:current_user])
end
......
......@@ -12,6 +12,8 @@ module Types
description: 'ID (global ID) of the commit'
field :sha, type: GraphQL::STRING_TYPE, null: false,
description: 'SHA1 ID of the commit'
field :short_id, type: GraphQL::STRING_TYPE, null: false,
description: 'Short SHA1 ID of the commit'
field :title, type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true,
description: 'Title of the commit message'
markdown_field :title_html, null: true
......
......@@ -92,6 +92,8 @@ module Types
description: 'Indicates if there is a rebase currently in progress for the merge request'
field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true,
description: 'Default merge commit message of the merge request'
field :default_merge_commit_message_with_description, GraphQL::STRING_TYPE, null: true,
description: 'Default merge commit message of the merge request with description'
field :merge_ongoing, GraphQL::BOOLEAN_TYPE, method: :merge_ongoing?, null: false,
description: 'Indicates if a merge is currently occurring'
field :source_branch_exists, GraphQL::BOOLEAN_TYPE,
......@@ -153,6 +155,16 @@ module Types
field :approved_by, Types::UserType.connection_type, null: true,
description: 'Users who approved the merge request'
field :squash_on_merge, GraphQL::BOOLEAN_TYPE, null: false, method: :squash_on_merge?,
description: 'Indicates if squash on merge is enabled'
field :available_auto_merge_strategies, [GraphQL::STRING_TYPE], null: true, calls_gitaly: true,
description: 'Array of available auto merge strategies'
field :has_ci, GraphQL::BOOLEAN_TYPE, null: false, method: :has_ci?,
description: 'Indicates if the merge request has CI'
field :mergeable, GraphQL::BOOLEAN_TYPE, null: false, method: :mergeable?, calls_gitaly: true,
description: 'Indicates if the merge request is mergeable'
field :commits_without_merge_commits, Types::CommitType.connection_type, null: true,
calls_gitaly: true, description: 'Merge request commits excluding merge commits'
def approved_by
object.approved_by_users
......@@ -203,6 +215,18 @@ module Types
def discussion_locked
!!object.discussion_locked
end
def default_merge_commit_message_with_description
object.default_merge_commit_message(include_description: true)
end
def available_auto_merge_strategies
AutoMergeService.new(object.project, current_user).available_strategies(object)
end
def commits_without_merge_commits
object.recent_commits.without_merge_commits
end
end
end
......
......@@ -107,6 +107,8 @@ module Types
description: 'Indicates if issues referenced by merge requests and commits within the default branch are closed automatically'
field :suggestion_commit_message, GraphQL::STRING_TYPE, null: true,
description: 'The commit message used to apply merge request suggestions'
field :squash_read_only, GraphQL::BOOLEAN_TYPE, null: false, method: :squash_readonly?,
description: 'Indicates if squash readonly is enabled'
field :namespace, Types::NamespaceType, null: true,
description: 'Namespace of the project'
......
......@@ -3075,6 +3075,11 @@ type Commit {
"""
sha: String!
"""
Short SHA1 ID of the commit
"""
shortId: String!
"""
Rendered HTML of the commit signature
"""
......@@ -3168,6 +3173,26 @@ enum CommitActionMode {
UPDATE
}
"""
The connection type for Commit.
"""
type CommitConnection {
"""
A list of edges.
"""
edges: [CommitEdge]
"""
A list of nodes.
"""
nodes: [Commit]
"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
}
"""
Autogenerated input type of CommitCreate
"""
......@@ -3223,6 +3248,21 @@ type CommitCreatePayload {
errors: [String!]!
}
"""
An edge in a connection.
"""
type CommitEdge {
"""
A cursor for use in pagination.
"""
cursor: String!
"""
The item at the end of the edge.
"""
node: Commit
}
enum CommitEncoding {
"""
Base64 encoding
......@@ -12932,11 +12972,41 @@ type MergeRequest implements CurrentUserTodos & Noteable {
"""
autoMergeEnabled: Boolean!
"""
Array of available auto merge strategies
"""
availableAutoMergeStrategies: [String!]
"""
Number of commits in the merge request
"""
commitCount: Int
"""
Merge request commits excluding merge commits
"""
commitsWithoutMergeCommits(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): CommitConnection
"""
Indicates if the merge request has conflicts
"""
......@@ -12982,6 +13052,11 @@ type MergeRequest implements CurrentUserTodos & Noteable {
"""
defaultMergeCommitMessage: String
"""
Default merge commit message of the merge request with description
"""
defaultMergeCommitMessageWithDescription: String
"""
Description of the merge request (Markdown rendered as HTML for caching)
"""
......@@ -13057,6 +13132,11 @@ type MergeRequest implements CurrentUserTodos & Noteable {
"""
forceRemoveSourceBranch: Boolean
"""
Indicates if the merge request has CI
"""
hasCi: Boolean!
"""
The pipeline running on the branch HEAD of the merge request
"""
......@@ -13122,11 +13202,20 @@ type MergeRequest implements CurrentUserTodos & Noteable {
"""
mergeStatus: String
"""
"""
mergeTrainsCount: Int
"""
Indicates if the merge has been set to be merged when its pipeline succeeds (MWPS)
"""
mergeWhenPipelineSucceeds: Boolean
"""
Indicates if the merge request is mergeable
"""
mergeable: Boolean!
"""
Indicates if all discussions in the merge request have been resolved, allowing the merge request to be merged
"""
......@@ -13298,6 +13387,11 @@ type MergeRequest implements CurrentUserTodos & Noteable {
"""
sourceProjectId: Int
"""
Indicates if squash on merge is enabled
"""
squashOnMerge: Boolean!
"""
State of the merge request
"""
......@@ -15440,6 +15534,11 @@ type PageInfo {
}
type Pipeline {
"""
Indicates if the pipeline is active
"""
active: Boolean!
"""
Base SHA of the source branch
"""
......@@ -17496,6 +17595,11 @@ type Project {
"""
snippetsEnabled: Boolean
"""
Indicates if squash readonly is enabled
"""
squashReadOnly: Boolean!
"""
URL to connect to the project via SSH
"""
......
......@@ -8457,6 +8457,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "shortId",
"description": "Short SHA1 ID of the commit",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "signatureHtml",
"description": "Rendered HTML of the commit signature",
......@@ -8673,6 +8691,73 @@
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "CommitConnection",
"description": "The connection type for Commit.",
"fields": [
{
"name": "edges",
"description": "A list of edges.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "CommitEdge",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "nodes",
"description": "A list of nodes.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Commit",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pageInfo",
"description": "Information to aid in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PageInfo",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "CommitCreateInput",
......@@ -8835,6 +8920,51 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "CommitEdge",
"description": "An edge in a connection.",
"fields": [
{
"name": "cursor",
"description": "A cursor for use in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "node",
"description": "The item at the end of the edge.",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "Commit",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "CommitEncoding",
......@@ -35722,6 +35852,28 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "availableAutoMergeStrategies",
"description": "Array of available auto merge strategies",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "commitCount",
"description": "Number of commits in the merge request",
......@@ -35736,6 +35888,59 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "commitsWithoutMergeCommits",
"description": "Merge request commits excluding merge commits",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "CommitConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "conflicts",
"description": "Indicates if the merge request has conflicts",
......@@ -35853,6 +36058,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "defaultMergeCommitMessageWithDescription",
"description": "Default merge commit message of the merge request with description",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "description",
"description": "Description of the merge request (Markdown rendered as HTML for caching)",
......@@ -36061,6 +36280,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "hasCi",
"description": "Indicates if the merge request has CI",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "headPipeline",
"description": "The pipeline running on the branch HEAD of the merge request",
......@@ -36238,6 +36475,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mergeTrainsCount",
"description": "",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mergeWhenPipelineSucceeds",
"description": "Indicates if the merge has been set to be merged when its pipeline succeeds (MWPS)",
......@@ -36252,6 +36503,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mergeable",
"description": "Indicates if the merge request is mergeable",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mergeableDiscussionsState",
"description": "Indicates if all discussions in the merge request have been resolved, allowing the merge request to be merged",
......@@ -36696,6 +36965,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "squashOnMerge",
"description": "Indicates if squash on merge is enabled",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "state",
"description": "State of the merge request",
......@@ -45931,6 +46218,24 @@
"name": "Pipeline",
"description": null,
"fields": [
{
"name": "active",
"description": "Indicates if the pipeline is active",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "beforeSha",
"description": "Base SHA of the source branch",
......@@ -51186,6 +51491,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "squashReadOnly",
"description": "Indicates if squash readonly is enabled",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "sshUrlToRepo",
"description": "URL to connect to the project via SSH",
......@@ -530,6 +530,7 @@ Represents the code coverage summary for a project.
| `message` | String | Raw commit message |
| `pipelines` | PipelineConnection | Pipelines of the commit ordered latest first |
| `sha` | String! | SHA1 ID of the commit |
| `shortId` | String! | Short SHA1 ID of the commit |
| `signatureHtml` | String | Rendered HTML of the commit signature |
| `title` | String | Title of the commit message |
| `titleHtml` | String | The GitLab Flavored Markdown rendering of `title` |
......@@ -2020,11 +2021,14 @@ Autogenerated return type of MarkAsSpamSnippet.
| `assignees` | UserConnection | Assignees of the merge request |
| `author` | User | User who created this merge request |
| `autoMergeEnabled` | Boolean! | Indicates if auto merge is enabled for the merge request |
| `availableAutoMergeStrategies` | String! => Array | Array of available auto merge strategies |
| `commitCount` | Int | Number of commits in the merge request |
| `commitsWithoutMergeCommits` | CommitConnection | Merge request commits excluding merge commits |
| `conflicts` | Boolean! | Indicates if the merge request has conflicts |
| `createdAt` | Time! | Timestamp of when the merge request was created |
| `currentUserTodos` | TodoConnection! | Todos for the current user |
| `defaultMergeCommitMessage` | String | Default merge commit message of the merge request |
| `defaultMergeCommitMessageWithDescription` | String | Default merge commit message of the merge request with description |
| `description` | String | Description of the merge request (Markdown rendered as HTML for caching) |
| `descriptionHtml` | String | The GitLab Flavored Markdown rendering of `description` |
| `diffHeadSha` | String | Diff head SHA of the merge request |
......@@ -2035,6 +2039,7 @@ Autogenerated return type of MarkAsSpamSnippet.
| `discussions` | DiscussionConnection! | All discussions on this noteable |
| `downvotes` | Int! | Number of downvotes for the merge request |
| `forceRemoveSourceBranch` | Boolean | Indicates if the project settings will lead to source branch deletion after merge |
| `hasCi` | Boolean! | Indicates if the merge request has CI |
| `headPipeline` | Pipeline | The pipeline running on the branch HEAD of the merge request |
| `id` | ID! | ID of the merge request |
| `iid` | String! | Internal ID of the merge request |
......@@ -2044,7 +2049,9 @@ Autogenerated return type of MarkAsSpamSnippet.
| `mergeError` | String | Error message due to a merge error |
| `mergeOngoing` | Boolean! | Indicates if a merge is currently occurring |
| `mergeStatus` | String | Status of the merge request |
| `mergeTrainsCount` | Int | |
| `mergeWhenPipelineSucceeds` | Boolean | Indicates if the merge has been set to be merged when its pipeline succeeds (MWPS) |
| `mergeable` | Boolean! | Indicates if the merge request is mergeable |
| `mergeableDiscussionsState` | Boolean | Indicates if all discussions in the merge request have been resolved, allowing the merge request to be merged |
| `mergedAt` | Time | Timestamp of when the merge request was merged, null if not merged |
| `milestone` | Milestone | The milestone of the merge request |
......@@ -2063,6 +2070,7 @@ Autogenerated return type of MarkAsSpamSnippet.
| `sourceBranchProtected` | Boolean! | Indicates if the source branch is protected |
| `sourceProject` | Project | Source project of the merge request |
| `sourceProjectId` | Int | ID of the merge request source project |
| `squashOnMerge` | Boolean! | Indicates if squash on merge is enabled |
| `state` | MergeRequestState! | State of the merge request |
| `subscribed` | Boolean! | Indicates if the currently logged in user is subscribed to this merge request |
| `targetBranch` | String! | Target branch of the merge request |
......@@ -2403,6 +2411,7 @@ Information about pagination in a connection..
| Field | Type | Description |
| ----- | ---- | ----------- |
| `active` | Boolean! | Indicates if the pipeline is active |
| `beforeSha` | String | Base SHA of the source branch |
| `cancelable` | Boolean! | Specifies if a pipeline can be canceled |
| `committedAt` | Time | Timestamp of the pipeline's commit |
......@@ -2574,6 +2583,7 @@ Autogenerated return type of PipelineRetry.
| `sharedRunnersEnabled` | Boolean | Indicates if shared runners are enabled for the project |
| `snippets` | SnippetConnection | Snippets of the project |
| `snippetsEnabled` | Boolean | Indicates if Snippets are enabled for the current user |
| `squashReadOnly` | Boolean! | Indicates if squash readonly is enabled |
| `sshUrlToRepo` | String | URL to connect to the project via SSH |
| `starCount` | Int! | Number of times the project has been starred |
| `statistics` | ProjectStatistics | Statistics of the project |
......
......@@ -12,6 +12,14 @@ module EE
description: 'Number of approvals left'
field :approvals_required, GraphQL::INT_TYPE, null: true,
description: 'Number of approvals required'
field :merge_trains_count, GraphQL::INT_TYPE, null: true,
description: ''
end
def merge_trains_count
return unless object.target_project.merge_trains_enabled?
MergeTrain.total_count_in_train(object)
end
end
end
......
......@@ -6,4 +6,19 @@ RSpec.describe Types::Ci::PipelineType do
specify { expect(described_class.graphql_name).to eq('Pipeline') }
specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Ci::Pipeline) }
it 'contains attributes related to a pipeline' do
expected_fields = %w[
id iid sha before_sha status detailed_status config_source duration
coverage created_at updated_at started_at finished_at committed_at
stages user retryable cancelable jobs source_job downstream
upstream path project active user_permissions
]
if Gitlab.ee?
expected_fields << 'security_report_summary'
end
expect(described_class).to have_graphql_fields(*expected_fields)
end
end
......@@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['Commit'] do
it 'contains attributes related to commit' do
expect(described_class).to have_graphql_fields(
:id, :sha, :title, :description, :description_html, :message, :title_html, :authored_date,
:id, :sha, :short_id, :title, :description, :description_html, :message, :title_html, :authored_date,
:author_name, :author_gravatar, :author, :web_url, :web_path,
:pipelines, :signature_html
)
......
......@@ -28,12 +28,15 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
milestone assignees participants subscribed labels discussion_locked time_estimate
total_time_spent reference author merged_at commit_count current_user_todos
conflicts auto_merge_enabled approved_by source_branch_protected
default_merge_commit_message_with_description squash_on_merge available_auto_merge_strategies
has_ci mergeable commits_without_merge_commits
]
if Gitlab.ee?
expected_fields << 'approved'
expected_fields << 'approvals_left'
expected_fields << 'approvals_required'
expected_fields << 'merge_trains_count'
end
expect(described_class).to have_graphql_fields(*expected_fields)
......
......@@ -31,7 +31,7 @@ RSpec.describe GitlabSchema.types['Project'] do
container_expiration_policy service_desk_enabled service_desk_address
issue_status_counts terraform_states alert_management_integrations
container_repositories container_repositories_count
pipeline_analytics total_pipeline_duration
pipeline_analytics total_pipeline_duration squash_read_only
]
expect(described_class).to include_graphql_fields(*expected_fields)
......
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