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 ...@@ -65,6 +65,7 @@ module Types
raise ArgumentError, 'Please provide a `milestone` within `deprecated`' unless milestone raise ArgumentError, 'Please provide a `milestone` within `deprecated`' unless milestone
raise ArgumentError, 'Please provide a `reason` within `deprecated`' unless reason 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}" deprecated_in = "Deprecated in #{milestone}"
kwargs[:deprecation_reason] = "#{reason}. #{deprecated_in}" kwargs[:deprecation_reason] = "#{reason}. #{deprecated_in}"
......
...@@ -44,7 +44,7 @@ module Types ...@@ -44,7 +44,7 @@ module Types
field :latest_pipeline, field :latest_pipeline,
type: Types::Ci::PipelineType, type: Types::Ci::PipelineType,
null: true, null: true,
deprecated: { reason: 'Use `pipelines`', milestone: 12.5 }, deprecated: { reason: 'Use `pipelines`', milestone: '12.5' },
description: 'Latest pipeline of the commit', description: 'Latest pipeline of the commit',
resolver: Resolvers::CommitPipelinesResolver.last resolver: Resolvers::CommitPipelinesResolver.last
end end
......
...@@ -18,7 +18,7 @@ module Types ...@@ -18,7 +18,7 @@ module Types
description: 'Timestamp of the issue\'s last activity' description: 'Timestamp of the issue\'s last activity'
field :token, GraphQL::STRING_TYPE, null: false, 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' description: 'API token for the Grafana integration'
def token def token
......
...@@ -75,7 +75,7 @@ module Types ...@@ -75,7 +75,7 @@ module Types
field :rebase_in_progress, GraphQL::BOOLEAN_TYPE, method: :rebase_in_progress?, null: false, calls_gitaly: true, 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' 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, 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' description: 'Default merge commit message of the merge request'
field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true, field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true,
description: 'Default merge commit message of the merge request' description: 'Default merge commit message of the merge request'
......
...@@ -301,7 +301,7 @@ Example: ...@@ -301,7 +301,7 @@ Example:
```ruby ```ruby
field :token, GraphQL::STRING_TYPE, null: true, 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' description: 'Token for login'
``` ```
...@@ -321,7 +321,7 @@ Example: ...@@ -321,7 +321,7 @@ Example:
```ruby ```ruby
field :designs, ::Types::DesignManagement::DesignCollectionType, null: true, 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', description: 'The designs associated with this issue',
``` ```
......
...@@ -15,7 +15,7 @@ module EE ...@@ -15,7 +15,7 @@ module EE
field :designs, ::Types::DesignManagement::DesignCollectionType, null: true, field :designs, ::Types::DesignManagement::DesignCollectionType, null: true,
method: :design_collection, method: :design_collection,
deprecated: { reason: 'Use `designCollection`', milestone: 12.2 }, deprecated: { reason: 'Use `designCollection`', milestone: '12.2' },
description: 'The designs associated with this issue' description: 'The designs associated with this issue'
field :design_collection, ::Types::DesignManagement::DesignCollectionType, null: true, field :design_collection, ::Types::DesignManagement::DesignCollectionType, null: true,
......
...@@ -203,7 +203,7 @@ describe Types::BaseField do ...@@ -203,7 +203,7 @@ describe Types::BaseField do
end end
it 'raises an error if a required property is missing', :aggregate_failures do 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, ArgumentError,
'Please provide a `reason` within `deprecated`' 'Please provide a `reason` within `deprecated`'
) )
...@@ -212,37 +212,44 @@ describe Types::BaseField do ...@@ -212,37 +212,44 @@ describe Types::BaseField do
'Please provide a `milestone` within `deprecated`' 'Please provide a `milestone` within `deprecated`'
) )
end 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 end
it 'adds a formatted `deprecated_reason` to the field' do 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 end
it 'appends to the description if given' do it 'appends to the description if given' do
field = test_field( field = test_field(
deprecated: { milestone: 1.0, reason: 'Deprecation reason' }, deprecated: { milestone: '1.10', reason: 'Deprecation reason' },
description: 'Field description' 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 end
it 'does not append to the description if it is absent' do 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 expect(field.description).to be_nil
end end
it 'interacts well with the `feature_flag` property' do it 'interacts well with the `feature_flag` property' do
field = test_field( field = test_field(
deprecated: { milestone: 1.0, reason: 'Deprecation reason' }, deprecated: { milestone: '1.10', reason: 'Deprecation reason' },
description: 'Field description', description: 'Field description',
feature_flag: 'foo_flag' 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 end
end end
...@@ -76,7 +76,7 @@ describe Gitlab::Graphql::Docs::Renderer do ...@@ -76,7 +76,7 @@ describe Gitlab::Graphql::Docs::Renderer do
Class.new(Types::BaseObject) do Class.new(Types::BaseObject) do
graphql_name 'DeprecatedTest' 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
end end
...@@ -86,7 +86,7 @@ describe Gitlab::Graphql::Docs::Renderer do ...@@ -86,7 +86,7 @@ describe Gitlab::Graphql::Docs::Renderer do
| Name | Type | Description | | 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 DOC
is_expected.to include(expectation) 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