Commit 7389c105 authored by Luke Duncalfe's avatar Luke Duncalfe Committed by Dmytro Zaporozhets (DZ)

Expose copyState on GraphQL DesignCollection type

https://gitlab.com/gitlab-org/gitlab/-/issues/13426
parent 9930ad74
# 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 ...@@ -39,6 +39,10 @@ module Types
null: true, null: true,
resolver: ::Resolvers::DesignManagement::DesignResolver, resolver: ::Resolvers::DesignManagement::DesignResolver,
description: 'Find a specific design' description: 'Find a specific design'
field :copy_state, ::Types::DesignManagement::DesignCollectionCopyStateEnum,
null: true,
description: 'Copy state of the design collection'
end end
end end
end end
---
title: Add DesignCollection copyState GraphQL field
merge_request: 42919
author:
type: added
...@@ -3919,6 +3919,11 @@ type DesignAtVersionEdge { ...@@ -3919,6 +3919,11 @@ type DesignAtVersionEdge {
A collection of designs A collection of designs
""" """
type DesignCollection { type DesignCollection {
"""
Copy state of the design collection
"""
copyState: DesignCollectionCopyState
""" """
Find a specific design Find a specific design
""" """
...@@ -4046,6 +4051,26 @@ type DesignCollection { ...@@ -4046,6 +4051,26 @@ type DesignCollection {
): DesignVersionConnection! ): 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. The connection type for Design.
""" """
......
...@@ -10789,6 +10789,20 @@ ...@@ -10789,6 +10789,20 @@
"name": "DesignCollection", "name": "DesignCollection",
"description": "A collection of designs", "description": "A collection of designs",
"fields": [ "fields": [
{
"name": "copyState",
"description": "Copy state of the design collection",
"args": [
],
"type": {
"kind": "ENUM",
"name": "DesignCollectionCopyState",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "design", "name": "design",
"description": "Find a specific design", "description": "Find a specific design",
...@@ -11106,6 +11120,35 @@ ...@@ -11106,6 +11120,35 @@
"enumValues": null, "enumValues": null,
"possibleTypes": 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", "kind": "OBJECT",
"name": "DesignConnection", "name": "DesignConnection",
...@@ -685,6 +685,7 @@ A collection of designs. ...@@ -685,6 +685,7 @@ A collection of designs.
| Field | Type | Description | | Field | Type | Description |
| ----- | ---- | ----------- | | ----- | ---- | ----------- |
| `copyState` | DesignCollectionCopyState | Copy state of the design collection |
| `design` | Design | Find a specific design | | `design` | Design | Find a specific design |
| `designAtVersion` | DesignAtVersion | Find a design as of a version | | `designAtVersion` | DesignAtVersion | Find a design as of a version |
| `issue` | Issue! | Issue associated with the design collection | | `issue` | Issue! | Issue associated with the design collection |
...@@ -3027,6 +3028,16 @@ Mode of a commit action. ...@@ -3027,6 +3028,16 @@ Mode of a commit action.
| `PASSED_VALIDATION` | Site validation process finished successfully | | `PASSED_VALIDATION` | Site validation process finished successfully |
| `PENDING_VALIDATION` | Site validation process has not started | | `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 ### DesignVersionEvent
Mutation event of a design within a version. 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 ...@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['DesignCollection'] do
it { expect(described_class).to require_graphql_authorizations(:read_design) } it { expect(described_class).to require_graphql_authorizations(:read_design) }
it 'has the expected fields' do 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) expect(described_class).to have_graphql_fields(*expected_fields)
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