summaryrefslogtreecommitdiff
path: root/app/graphql
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-20 09:09:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-20 09:09:22 +0000
commit196ada0844fff7642463fbd08a44609a1e1fa713 (patch)
tree7160cacde0b36d73a35e84d685824dd8633dfc0a /app/graphql
parente380e59ef5d1aa03922df49626c302da5eb30699 (diff)
downloadgitlab-ce-196ada0844fff7642463fbd08a44609a1e1fa713.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/types/base_field.rb24
-rw-r--r--app/graphql/types/commit_type.rb4
-rw-r--r--app/graphql/types/grafana_integration_type.rb4
-rw-r--r--app/graphql/types/merge_request_type.rb5
4 files changed, 30 insertions, 7 deletions
diff --git a/app/graphql/types/base_field.rb b/app/graphql/types/base_field.rb
index 1b296f8d52b..148675e9d9e 100644
--- a/app/graphql/types/base_field.rb
+++ b/app/graphql/types/base_field.rb
@@ -12,6 +12,7 @@ module Types
kwargs[:complexity] = field_complexity(kwargs[:resolver_class], kwargs[:complexity])
@feature_flag = kwargs[:feature_flag]
kwargs = check_feature_flag(kwargs)
+ kwargs = handle_deprecated(kwargs)
super(*args, **kwargs, &block)
end
@@ -41,7 +42,7 @@ module Types
attr_reader :feature_flag
def feature_documentation_message(key, description)
- "#{description}. Available only when feature flag `#{key}` is enabled."
+ "#{description}. Available only when feature flag `#{key}` is enabled"
end
def check_feature_flag(args)
@@ -51,6 +52,27 @@ module Types
args
end
+ def handle_deprecated(kwargs)
+ if kwargs[:deprecation_reason].present?
+ raise ArgumentError, 'Use `deprecated` property instead of `deprecation_reason`. ' \
+ 'See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#deprecating-fields'
+ end
+
+ deprecation = kwargs.delete(:deprecated)
+ return kwargs unless deprecation
+
+ milestone, reason = deprecation.values_at(:milestone, :reason).map(&:presence)
+
+ raise ArgumentError, 'Please provide a `milestone` within `deprecated`' unless milestone
+ raise ArgumentError, 'Please provide a `reason` within `deprecated`' unless reason
+
+ deprecated_in = "Deprecated in #{milestone}"
+ kwargs[:deprecation_reason] = "#{reason}. #{deprecated_in}"
+ kwargs[:description] += ". #{deprecated_in}: #{reason}" if kwargs[:description]
+
+ kwargs
+ end
+
def field_complexity(resolver_class, current)
return current if current.present? && current > 0
diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb
index eb25e3651a8..437da3bb585 100644
--- a/app/graphql/types/commit_type.rb
+++ b/app/graphql/types/commit_type.rb
@@ -44,8 +44,8 @@ module Types
field :latest_pipeline,
type: Types::Ci::PipelineType,
null: true,
- description: "Latest pipeline of the commit",
- deprecation_reason: 'Use pipelines',
+ deprecated: { reason: 'Use `pipelines`', milestone: 12.5 },
+ description: 'Latest pipeline of the commit',
resolver: Resolvers::CommitPipelinesResolver.last
end
end
diff --git a/app/graphql/types/grafana_integration_type.rb b/app/graphql/types/grafana_integration_type.rb
index f234008ee0d..71018f6ce0a 100644
--- a/app/graphql/types/grafana_integration_type.rb
+++ b/app/graphql/types/grafana_integration_type.rb
@@ -18,8 +18,8 @@ module Types
description: 'Timestamp of the issue\'s last activity'
field :token, GraphQL::STRING_TYPE, null: false,
- deprecation_reason: 'Plain text token has been masked for security reasons',
- description: 'API token for the Grafana integration. Field is permanently masked.'
+ deprecated: { reason: 'Plain text token has been masked for security reasons', milestone: 12.7 },
+ description: 'API token for the Grafana integration'
def token
object.masked_token
diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb
index 0da95b367d8..8cb439cb465 100644
--- a/app/graphql/types/merge_request_type.rb
+++ b/app/graphql/types/merge_request_type.rb
@@ -74,8 +74,9 @@ module Types
description: 'Rebase commit SHA of the merge request'
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, deprecation_reason: "Renamed to defaultMergeCommitMessage",
- description: 'Deprecated - renamed to defaultMergeCommitMessage'
+ field :merge_commit_message, GraphQL::STRING_TYPE, method: :default_merge_commit_message, null: true,
+ 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'
field :merge_ongoing, GraphQL::BOOLEAN_TYPE, method: :merge_ongoing?, null: false,