Commit 96218ca0 authored by James Fargher's avatar James Fargher

Merge branch '336292-convert-old-graphql-types-to-newer-type-names-10' into 'master'

Convert old GraphQL types to newer type names (Part 10) [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!75950
parents 3db05b9d 16808abf
......@@ -76,7 +76,7 @@ module Types
description: 'Indicates the job is active.'
field :stuck, GraphQL::Types::Boolean, null: false, method: :stuck?,
description: 'Indicates the job is stuck.'
field :coverage, GraphQL::FLOAT_TYPE, null: true,
field :coverage, GraphQL::Types::Float, null: true,
description: 'Coverage level of the job.'
field :created_by_tag, GraphQL::Types::Boolean, null: false,
description: 'Whether the job was created by a tag.'
......
......@@ -45,7 +45,7 @@ module Types
field :queued_duration, Types::DurationType, null: true,
description: 'How long the pipeline was queued before starting.'
field :coverage, GraphQL::FLOAT_TYPE, null: true,
field :coverage, GraphQL::Types::Float, null: true,
description: 'Coverage percentage.'
field :created_at, Types::TimeType, null: false,
......
......@@ -18,7 +18,7 @@ module Types
field :classname, GraphQL::Types::String, null: true,
description: 'Classname of the test case.'
field :execution_time, GraphQL::FLOAT_TYPE, null: true,
field :execution_time, GraphQL::Types::Float, null: true,
description: 'Test case execution time in seconds.'
field :file, GraphQL::Types::String, null: true,
......
......@@ -7,7 +7,7 @@ module Types
graphql_name 'TestReportTotal'
description 'Total test report statistics.'
field :time, GraphQL::FLOAT_TYPE, null: true,
field :time, GraphQL::Types::Float, null: true,
description: 'Total duration of the tests.'
field :count, GraphQL::Types::Int, null: true,
......
......@@ -12,7 +12,7 @@ module Types
field :name, GraphQL::Types::String, null: true,
description: 'Name of the test suite.'
field :total_time, GraphQL::FLOAT_TYPE, null: true,
field :total_time, GraphQL::Types::Float, null: true,
description: 'Total duration of the tests in the test suite.'
field :total_count, GraphQL::Types::Int, null: true,
......
......@@ -12,7 +12,7 @@ module Types
field :name, GraphQL::Types::String, null: true,
description: 'Name of the test suite.'
field :total_time, GraphQL::FLOAT_TYPE, null: true,
field :total_time, GraphQL::Types::Float, null: true,
description: 'Total duration of the tests in the test suite.'
field :total_count, GraphQL::Types::Int, null: true,
......
......@@ -3,7 +3,7 @@
module Types
# rubocop: disable Graphql/AuthorizeTypes
class MergeRequestConnectionType < Types::CountableConnectionType
field :total_time_to_merge, GraphQL::FLOAT_TYPE, null: true,
field :total_time_to_merge, GraphQL::Types::Float, null: true,
description: 'Total sum of time to merge, in seconds, for the collection of merge requests.'
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -6,26 +6,26 @@ module Types
authorize :read_statistics
field :commit_count, GraphQL::FLOAT_TYPE, null: false,
field :commit_count, GraphQL::Types::Float, null: false,
description: 'Commit count of the project.'
field :storage_size, GraphQL::FLOAT_TYPE, null: false,
field :storage_size, GraphQL::Types::Float, null: false,
description: 'Storage size of the project in bytes.'
field :repository_size, GraphQL::FLOAT_TYPE, null: false,
field :repository_size, GraphQL::Types::Float, null: false,
description: 'Repository size of the project in bytes.'
field :lfs_objects_size, GraphQL::FLOAT_TYPE, null: false,
field :lfs_objects_size, GraphQL::Types::Float, null: false,
description: 'Large File Storage (LFS) object size of the project in bytes.'
field :build_artifacts_size, GraphQL::FLOAT_TYPE, null: false,
field :build_artifacts_size, GraphQL::Types::Float, null: false,
description: 'Build artifacts size of the project in bytes.'
field :packages_size, GraphQL::FLOAT_TYPE, null: false,
field :packages_size, GraphQL::Types::Float, null: false,
description: 'Packages size of the project in bytes.'
field :wiki_size, GraphQL::FLOAT_TYPE, null: true,
field :wiki_size, GraphQL::Types::Float, null: true,
description: 'Wiki size of the project in bytes.'
field :snippets_size, GraphQL::FLOAT_TYPE, null: true,
field :snippets_size, GraphQL::Types::Float, null: true,
description: 'Snippets size of the project in bytes.'
field :pipeline_artifacts_size, GraphQL::FLOAT_TYPE, null: true,
field :pipeline_artifacts_size, GraphQL::Types::Float, null: true,
description: 'CI Pipeline artifacts size in bytes.'
field :uploads_size, GraphQL::FLOAT_TYPE, null: true,
field :uploads_size, GraphQL::Types::Float, null: true,
description: 'Uploads size of the project in bytes.'
end
end
......@@ -6,14 +6,14 @@ module Types
authorize :read_statistics
field :storage_size, GraphQL::FLOAT_TYPE, null: false, description: 'Total storage in bytes.'
field :repository_size, GraphQL::FLOAT_TYPE, null: false, description: 'Git repository size in bytes.'
field :lfs_objects_size, GraphQL::FLOAT_TYPE, null: false, description: 'LFS objects size in bytes.'
field :build_artifacts_size, GraphQL::FLOAT_TYPE, null: false, description: 'CI artifacts size in bytes.'
field :packages_size, GraphQL::FLOAT_TYPE, null: false, description: 'Packages size in bytes.'
field :wiki_size, GraphQL::FLOAT_TYPE, null: false, description: 'Wiki size in bytes.'
field :snippets_size, GraphQL::FLOAT_TYPE, null: false, description: 'Snippets size in bytes.'
field :pipeline_artifacts_size, GraphQL::FLOAT_TYPE, null: false, description: 'CI pipeline artifacts size in bytes.'
field :uploads_size, GraphQL::FLOAT_TYPE, null: false, description: 'Uploads size in bytes.'
field :storage_size, GraphQL::Types::Float, null: false, description: 'Total storage in bytes.'
field :repository_size, GraphQL::Types::Float, null: false, description: 'Git repository size in bytes.'
field :lfs_objects_size, GraphQL::Types::Float, null: false, description: 'LFS objects size in bytes.'
field :build_artifacts_size, GraphQL::Types::Float, null: false, description: 'CI artifacts size in bytes.'
field :packages_size, GraphQL::Types::Float, null: false, description: 'Packages size in bytes.'
field :wiki_size, GraphQL::Types::Float, null: false, description: 'Wiki size in bytes.'
field :snippets_size, GraphQL::Types::Float, null: false, description: 'Snippets size in bytes.'
field :pipeline_artifacts_size, GraphQL::Types::Float, null: false, description: 'CI pipeline artifacts size in bytes.'
field :uploads_size, GraphQL::Types::Float, null: false, description: 'Uploads size in bytes.'
end
end
......@@ -152,8 +152,8 @@ The `iid`, `title` and `description` are _scalar_ GraphQL types.
`title` and `description` are regular `GraphQL::Types::String` types.
Note that the old scalar types `GraphQL:ID`, `GraphQL::INT_TYPE`, `GraphQL::STRING_TYPE`,
and `GraphQL:BOOLEAN_TYPE` are no longer allowed. Please use `GraphQL::Types::ID`,
`GraphQL::Types::Int`, `GraphQL::Types::String`, and `GraphQL::Types::Boolean`.
`GraphQL:BOOLEAN_TYPE`, and `GraphQL::FLOAT_TYPE` are no longer allowed. Please use `GraphQL::Types::ID`,
`GraphQL::Types::Int`, `GraphQL::Types::String`, `GraphQL::Types::Boolean`, and `GraphQL::Types::Float`.
When exposing a model through the GraphQL API, we do so by creating a
new type in `app/graphql/types`. You can also declare custom GraphQL data types
......
......@@ -9,11 +9,11 @@ module EE
extend ::Gitlab::Utils::Override
prepended do
argument :public_projects_minutes_cost_factor, GraphQL::FLOAT_TYPE,
argument :public_projects_minutes_cost_factor, GraphQL::Types::Float,
required: false,
description: 'Public projects\' "minutes cost factor" associated with the runner (GitLab.com only).'
argument :private_projects_minutes_cost_factor, GraphQL::FLOAT_TYPE,
argument :private_projects_minutes_cost_factor, GraphQL::Types::Float,
required: false,
description: 'Private projects\' "minutes cost factor" associated with the runner (GitLab.com only).'
end
......
......@@ -7,9 +7,9 @@ module EE
extend ActiveSupport::Concern
prepended do
field :public_projects_minutes_cost_factor, GraphQL::FLOAT_TYPE, null: true,
field :public_projects_minutes_cost_factor, GraphQL::Types::Float, null: true,
description: 'Public projects\' "minutes cost factor" associated with the runner (GitLab.com only).'
field :private_projects_minutes_cost_factor, GraphQL::FLOAT_TYPE, null: true,
field :private_projects_minutes_cost_factor, GraphQL::Types::Float, null: true,
description: 'Private projects\' "minutes cost factor" associated with the runner (GitLab.com only).'
end
end
......
......@@ -7,17 +7,17 @@ module EE
prepended do
field :additional_purchased_storage_size,
GraphQL::FLOAT_TYPE,
GraphQL::Types::Float,
null: true,
description: 'Additional storage purchased for the root namespace in bytes.'
field :total_repository_size_excess,
GraphQL::FLOAT_TYPE,
GraphQL::Types::Float,
null: true,
description: 'Total excess repository size of all projects in the root namespace in bytes.'
field :total_repository_size,
GraphQL::FLOAT_TYPE,
GraphQL::Types::Float,
null: true,
description: 'Total repository size of all projects in the root namespace in bytes.'
......@@ -33,13 +33,13 @@ module EE
description: 'Number of projects in the root namespace where the repository size exceeds the limit.'
field :actual_repository_size_limit,
GraphQL::FLOAT_TYPE,
GraphQL::Types::Float,
null: true,
description: 'Size limit for repositories in the namespace in bytes.',
method: :actual_size_limit
field :storage_size_limit,
GraphQL::FLOAT_TYPE,
GraphQL::Types::Float,
null: true,
description: 'Total storage limit of the root namespace in bytes.'
......
......@@ -97,12 +97,12 @@ module EE
description: 'DAST Site Validations associated with the project.'
field :repository_size_excess,
GraphQL::FLOAT_TYPE,
GraphQL::Types::Float,
null: true,
description: 'Size of repository that exceeds the limit in bytes.'
field :actual_repository_size_limit,
GraphQL::FLOAT_TYPE,
GraphQL::Types::Float,
null: true,
description: 'Size limit for the repository in bytes.',
method: :actual_size_limit
......
......@@ -7,7 +7,7 @@ module Types
graphql_name 'CodeCoverageActivity'
description 'Represents the code coverage activity for a group'
field :average_coverage, GraphQL::FLOAT_TYPE, null: true,
field :average_coverage, GraphQL::Types::Float, null: true,
description: 'Average percentage of the different code coverage results available for the group.'
field :coverage_count, GraphQL::Types::Int, null: true,
......
......@@ -7,7 +7,7 @@ module Types
graphql_name 'CodeCoverageSummary'
description 'Represents the code coverage summary for a project'
field :average_coverage, GraphQL::FLOAT_TYPE, null: true,
field :average_coverage, GraphQL::Types::Float, null: true,
description: 'Average percentage of the different code coverage results available for the project.'
field :coverage_count, GraphQL::Types::Int, null: true,
......
......@@ -8,17 +8,17 @@ module Types
class NamespaceMonthlyUsageType < BaseObject
graphql_name 'CiMinutesNamespaceMonthlyUsage'
field :month, ::GraphQL::STRING_TYPE, null: true,
field :month, ::GraphQL::Types::String, null: true,
description: 'Month related to the usage data.'
field :minutes, ::GraphQL::INT_TYPE, null: true,
field :minutes, ::GraphQL::Types::Int, null: true,
method: :amount_used,
description: 'Total number of minutes used by all projects in the namespace.'
field :projects, ::Types::Ci::Minutes::ProjectMonthlyUsageType.connection_type, null: true,
description: 'CI minutes usage data for projects in the namespace.'
field :shared_runners_duration, ::GraphQL::INT_TYPE, null: true,
field :shared_runners_duration, ::GraphQL::Types::Int, null: true,
description: 'Total numbers of minutes used by the shared runners in the namespace.'
def month
......
......@@ -8,11 +8,11 @@ module Types
class ProjectMonthlyUsageType < BaseObject
graphql_name 'CiMinutesProjectMonthlyUsage'
field :minutes, ::GraphQL::INT_TYPE, null: true,
field :minutes, ::GraphQL::Types::Int, null: true,
method: :amount_used,
description: 'Number of CI minutes used by the project in the month.'
field :name, ::GraphQL::STRING_TYPE, null: true,
field :name, GraphQL::Types::String, null: true,
description: 'Name of the project.'
def name
......
......@@ -24,11 +24,12 @@ module RuboCop
MSG_INT = 'Avoid using GraphQL::INT_TYPE. Use GraphQL::Types::Int instead'
MSG_STRING = 'Avoid using GraphQL::STRING_TYPE. Use GraphQL::Types::String instead'
MSG_BOOLEAN = 'Avoid using GraphQL::BOOLEAN_TYPE. Use GraphQL::Types::Boolean instead'
MSG_FLOAT = 'Avoid using GraphQL::FLOAT_TYPE. Use GraphQL::Types::Float instead'
def_node_matcher :has_old_type?, <<~PATTERN
(send nil? {:field :argument}
(sym _)
(const (const nil? :GraphQL) ${:ID_TYPE :INT_TYPE :STRING_TYPE :BOOLEAN_TYPE})
(const {(const nil? :GraphQL) (const (cbase) :GraphQL)} ${:ID_TYPE :INT_TYPE :STRING_TYPE :BOOLEAN_TYPE :FLOAT_TYPE})
(...)?)
PATTERN
......
......@@ -10,10 +10,16 @@ RSpec.describe RuboCop::Cop::Graphql::OldTypes do
subject(:cop) { described_class.new }
where(:old_type, :message) do
'GraphQL::ID_TYPE' | 'Avoid using GraphQL::ID_TYPE. Use GraphQL::Types::ID instead'
'GraphQL::INT_TYPE' | 'Avoid using GraphQL::INT_TYPE. Use GraphQL::Types::Int instead'
'GraphQL::STRING_TYPE' | 'Avoid using GraphQL::STRING_TYPE. Use GraphQL::Types::String instead'
'GraphQL::BOOLEAN_TYPE' | 'Avoid using GraphQL::BOOLEAN_TYPE. Use GraphQL::Types::Boolean instead'
'GraphQL::ID_TYPE' | 'Avoid using GraphQL::ID_TYPE. Use GraphQL::Types::ID instead'
'GraphQL::INT_TYPE' | 'Avoid using GraphQL::INT_TYPE. Use GraphQL::Types::Int instead'
'GraphQL::STRING_TYPE' | 'Avoid using GraphQL::STRING_TYPE. Use GraphQL::Types::String instead'
'GraphQL::BOOLEAN_TYPE' | 'Avoid using GraphQL::BOOLEAN_TYPE. Use GraphQL::Types::Boolean instead'
'GraphQL::FLOAT_TYPE' | 'Avoid using GraphQL::FLOAT_TYPE. Use GraphQL::Types::Float instead'
'::GraphQL::ID_TYPE' | 'Avoid using GraphQL::ID_TYPE. Use GraphQL::Types::ID instead'
'::GraphQL::INT_TYPE' | 'Avoid using GraphQL::INT_TYPE. Use GraphQL::Types::Int instead'
'::GraphQL::STRING_TYPE' | 'Avoid using GraphQL::STRING_TYPE. Use GraphQL::Types::String instead'
'::GraphQL::BOOLEAN_TYPE' | 'Avoid using GraphQL::BOOLEAN_TYPE. Use GraphQL::Types::Boolean instead'
'::GraphQL::FLOAT_TYPE' | 'Avoid using GraphQL::FLOAT_TYPE. Use GraphQL::Types::Float instead'
end
with_them do
......@@ -27,7 +33,7 @@ RSpec.describe RuboCop::Cop::Graphql::OldTypes do
RUBY
end
it "adds an offense when an old type is used with other keywords" do
it 'adds an offense when an old type is used with other keywords' do
expect_offense(<<~RUBY)
class MyType
field :some_field, #{old_type}, null: true, description: 'My description'
......
......@@ -22,7 +22,7 @@ module Graphql
@type ||= begin
field_type = @field.type.respond_to?(:to_graphql) ? @field.type.to_graphql : @field.type
# The type could be nested. For example `[GraphQL::STRING_TYPE]`:
# The type could be nested. For example `[GraphQL::Types::String]`:
# - List
# - String!
# - String
......
......@@ -438,12 +438,12 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
mutation.description 'Make everything very pretty.'
mutation.argument :prettiness_factor,
type: GraphQL::FLOAT_TYPE,
type: GraphQL::Types::Float,
required: true,
description: 'How much prettier?'
mutation.argument :pulchritude,
type: GraphQL::FLOAT_TYPE,
type: GraphQL::Types::Float,
required: false,
description: 'How much prettier?',
deprecated: {
......
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