Commit 4f7f1dd3 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'ld-graphql-deprecated-milestone-as-string' into 'master'

Change GraphQL milestone property to be a String

See merge request gitlab-org/gitlab!28736
parents 90fe979d 008534b7
......@@ -65,6 +65,7 @@ module Types
raise ArgumentError, 'Please provide a `milestone` within `deprecated`' unless milestone
raise ArgumentError, 'Please provide a `reason` within `deprecated`' unless reason
raise ArgumentError, '`milestone` must be a `String`' unless milestone.is_a?(String)
deprecated_in = "Deprecated in #{milestone}"
kwargs[:deprecation_reason] = "#{reason}. #{deprecated_in}"
......
......@@ -44,7 +44,7 @@ module Types
field :latest_pipeline,
type: Types::Ci::PipelineType,
null: true,
deprecated: { reason: 'Use `pipelines`', milestone: 12.5 },
deprecated: { reason: 'Use `pipelines`', milestone: '12.5' },
description: 'Latest pipeline of the commit',
resolver: Resolvers::CommitPipelinesResolver.last
end
......
......@@ -18,7 +18,7 @@ module Types
description: 'Timestamp of the issue\'s last activity'
field :token, GraphQL::STRING_TYPE, null: false,
deprecated: { reason: 'Plain text token has been masked for security reasons', milestone: 12.7 },
deprecated: { reason: 'Plain text token has been masked for security reasons', milestone: '12.7' },
description: 'API token for the Grafana integration'
def token
......
......@@ -75,7 +75,7 @@ module Types
field :rebase_in_progress, GraphQL::BOOLEAN_TYPE, method: :rebase_in_progress?, null: false, calls_gitaly: true,
description: 'Indicates if there is a rebase currently in progress for the merge request'
field :merge_commit_message, GraphQL::STRING_TYPE, method: :default_merge_commit_message, null: true,
deprecated: { reason: 'Use `defaultMergeCommitMessage`', milestone: 11.8 },
deprecated: { reason: 'Use `defaultMergeCommitMessage`', milestone: '11.8' },
description: 'Default merge commit message of the merge request'
field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true,
description: 'Default merge commit message of the merge request'
......
......@@ -301,7 +301,7 @@ Example:
```ruby
field :token, GraphQL::STRING_TYPE, null: true,
deprecated: { reason: 'Login via token has been removed', milestone: 10.0 },
deprecated: { reason: 'Login via token has been removed', milestone: '10.0' },
description: 'Token for login'
```
......@@ -321,7 +321,7 @@ Example:
```ruby
field :designs, ::Types::DesignManagement::DesignCollectionType, null: true,
deprecated: { reason: 'Use `designCollection`', milestone: 10.0 },
deprecated: { reason: 'Use `designCollection`', milestone: '10.0' },
description: 'The designs associated with this issue',
```
......
......@@ -15,7 +15,7 @@ module EE
field :designs, ::Types::DesignManagement::DesignCollectionType, null: true,
method: :design_collection,
deprecated: { reason: 'Use `designCollection`', milestone: 12.2 },
deprecated: { reason: 'Use `designCollection`', milestone: '12.2' },
description: 'The designs associated with this issue'
field :design_collection, ::Types::DesignManagement::DesignCollectionType, null: true,
......
......@@ -203,7 +203,7 @@ describe Types::BaseField do
end
it 'raises an error if a required property is missing', :aggregate_failures do
expect { test_field(deprecated: { milestone: 1.0 }) }.to raise_error(
expect { test_field(deprecated: { milestone: '1.10' }) }.to raise_error(
ArgumentError,
'Please provide a `reason` within `deprecated`'
)
......@@ -212,37 +212,44 @@ describe Types::BaseField do
'Please provide a `milestone` within `deprecated`'
)
end
it 'raises an error if milestone is not a String', :aggregate_failures do
expect { test_field(deprecated: { milestone: 1.10, reason: 'Deprecation reason' }) }.to raise_error(
ArgumentError,
'`milestone` must be a `String`'
)
end
end
it 'adds a formatted `deprecated_reason` to the field' do
field = test_field(deprecated: { milestone: 1.0, reason: 'Deprecation reason' })
field = test_field(deprecated: { milestone: '1.10', reason: 'Deprecation reason' })
expect(field.deprecation_reason).to eq('Deprecation reason. Deprecated in 1.0')
expect(field.deprecation_reason).to eq('Deprecation reason. Deprecated in 1.10')
end
it 'appends to the description if given' do
field = test_field(
deprecated: { milestone: 1.0, reason: 'Deprecation reason' },
deprecated: { milestone: '1.10', reason: 'Deprecation reason' },
description: 'Field description'
)
expect(field.description).to eq('Field description. Deprecated in 1.0: Deprecation reason')
expect(field.description).to eq('Field description. Deprecated in 1.10: Deprecation reason')
end
it 'does not append to the description if it is absent' do
field = test_field(deprecated: { milestone: 1.0, reason: 'Deprecation reason' })
field = test_field(deprecated: { milestone: '1.10', reason: 'Deprecation reason' })
expect(field.description).to be_nil
end
it 'interacts well with the `feature_flag` property' do
field = test_field(
deprecated: { milestone: 1.0, reason: 'Deprecation reason' },
deprecated: { milestone: '1.10', reason: 'Deprecation reason' },
description: 'Field description',
feature_flag: 'foo_flag'
)
expect(field.description).to eq('Field description. Available only when feature flag `foo_flag` is enabled. Deprecated in 1.0: Deprecation reason')
expect(field.description).to eq('Field description. Available only when feature flag `foo_flag` is enabled. Deprecated in 1.10: Deprecation reason')
end
end
end
......@@ -76,7 +76,7 @@ describe Gitlab::Graphql::Docs::Renderer do
Class.new(Types::BaseObject) do
graphql_name 'DeprecatedTest'
field :foo, GraphQL::STRING_TYPE, null: false, deprecated: { reason: 'This is deprecated', milestone: 1.0 }, description: 'A description'
field :foo, GraphQL::STRING_TYPE, null: false, deprecated: { reason: 'This is deprecated', milestone: '1.10' }, description: 'A description'
end
end
......@@ -86,7 +86,7 @@ describe Gitlab::Graphql::Docs::Renderer do
| Name | Type | Description |
| --- | ---- | ---------- |
| `foo` **{warning-solid}** | String! | **Deprecated:** This is deprecated. Deprecated in 1.0 |
| `foo` **{warning-solid}** | String! | **Deprecated:** This is deprecated. Deprecated in 1.10 |
DOC
is_expected.to include(expectation)
......
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