Commit a52810fa authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch '13426-graphql' into 'master'

Expose copyState on GraphQL DesignCollection type

See merge request gitlab-org/gitlab!42919
parents 80ca9033 7389c105
# frozen_string_literal: true
module Types
module DesignManagement
class DesignCollectionCopyStateEnum < BaseEnum
graphql_name 'DesignCollectionCopyState'
description 'Copy state of a DesignCollection'
DESCRIPTION_VARIANTS = {
in_progress: 'is being copied',
error: 'encountered an error during a copy',
ready: 'has no copy in progress'
}.freeze
def self.description_variant(copy_state)
DESCRIPTION_VARIANTS[copy_state.to_sym] ||
(raise ArgumentError, "Unknown copy state: #{copy_state}")
end
::DesignManagement::DesignCollection.state_machines[:copy_state].states.keys.each do |copy_state|
value copy_state.upcase,
value: copy_state.to_s,
description: "The DesignCollection #{description_variant(copy_state)}"
end
end
end
end
......@@ -39,6 +39,10 @@ module Types
null: true,
resolver: ::Resolvers::DesignManagement::DesignResolver,
description: 'Find a specific design'
field :copy_state, ::Types::DesignManagement::DesignCollectionCopyStateEnum,
null: true,
description: 'Copy state of the design collection'
end
end
end
---
title: Add DesignCollection copyState GraphQL field
merge_request: 42919
author:
type: added
......@@ -3919,6 +3919,11 @@ type DesignAtVersionEdge {
A collection of designs
"""
type DesignCollection {
"""
Copy state of the design collection
"""
copyState: DesignCollectionCopyState
"""
Find a specific design
"""
......@@ -4046,6 +4051,26 @@ type DesignCollection {
): DesignVersionConnection!
}
"""
Copy state of a DesignCollection
"""
enum DesignCollectionCopyState {
"""
The DesignCollection encountered an error during a copy
"""
ERROR
"""
The DesignCollection is being copied
"""
IN_PROGRESS
"""
The DesignCollection has no copy in progress
"""
READY
}
"""
The connection type for Design.
"""
......
......@@ -10789,6 +10789,20 @@
"name": "DesignCollection",
"description": "A collection of designs",
"fields": [
{
"name": "copyState",
"description": "Copy state of the design collection",
"args": [
],
"type": {
"kind": "ENUM",
"name": "DesignCollectionCopyState",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "design",
"description": "Find a specific design",
......@@ -11106,6 +11120,35 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "DesignCollectionCopyState",
"description": "Copy state of a DesignCollection",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "READY",
"description": "The DesignCollection has no copy in progress",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "IN_PROGRESS",
"description": "The DesignCollection is being copied",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "ERROR",
"description": "The DesignCollection encountered an error during a copy",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "DesignConnection",
......@@ -685,6 +685,7 @@ A collection of designs.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `copyState` | DesignCollectionCopyState | Copy state of the design collection |
| `design` | Design | Find a specific design |
| `designAtVersion` | DesignAtVersion | Find a design as of a version |
| `issue` | Issue! | Issue associated with the design collection |
......@@ -3027,6 +3028,16 @@ Mode of a commit action.
| `PASSED_VALIDATION` | Site validation process finished successfully |
| `PENDING_VALIDATION` | Site validation process has not started |
### DesignCollectionCopyState
Copy state of a DesignCollection.
| Value | Description |
| ----- | ----------- |
| `ERROR` | The DesignCollection encountered an error during a copy |
| `IN_PROGRESS` | The DesignCollection is being copied |
| `READY` | The DesignCollection has no copy in progress |
### DesignVersionEvent
Mutation event of a design within a version.
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['DesignCollectionCopyState'] do
it { expect(described_class.graphql_name).to eq('DesignCollectionCopyState') }
it 'exposes the correct event states' do
expect(described_class.values.keys).to match_array(%w(READY IN_PROGRESS ERROR))
end
end
......@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['DesignCollection'] do
it { expect(described_class).to require_graphql_authorizations(:read_design) }
it 'has the expected fields' do
expected_fields = %i[project issue designs versions version designAtVersion design]
expected_fields = %i[project issue designs versions version designAtVersion design copyState]
expect(described_class).to have_graphql_fields(*expected_fields)
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