Commit b6216e88 authored by Michael Kozono's avatar Michael Kozono

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!66979
parents 6e9ec35e 760218e4
......@@ -446,9 +446,10 @@ Graphql/OldTypes:
Include:
- 'app/graphql/**/*'
- 'ee/app/graphql/**/*'
Exclude:
- 'spec/**/*.rb'
- 'ee/spec/**/*.rb'
- 'spec/graphql/**/*'
- 'spec/requests/api/graphql/**/*'
- 'ee/spec/graphql/**/*'
- 'ee/spec/requests/api/graphql/**/*'
RSpec/EnvAssignment:
Enable: true
......
......@@ -23,23 +23,6 @@ Graphql/Descriptions:
- 'ee/app/graphql/types/vulnerability_severity_enum.rb'
- 'ee/app/graphql/types/vulnerability_state_enum.rb'
# WIP See https://gitlab.com/gitlab-org/gitlab/-/issues/336292
Graphql/OldTypes:
Exclude:
- 'spec/**/*.rb'
- 'ee/spec/**/*.rb'
- 'ee/app/graphql/ee/mutations/ci/ci_cd_settings_update.rb'
- 'ee/app/graphql/ee/resolvers/issues_resolver.rb'
- 'ee/app/graphql/ee/resolvers/namespace_projects_resolver.rb'
- 'ee/app/graphql/ee/types/board_list_type.rb'
- 'ee/app/graphql/ee/types/boards/board_issue_input_base_type.rb'
- 'ee/app/graphql/ee/types/issue_connection_type.rb'
- 'ee/app/graphql/ee/types/issue_type.rb'
- 'ee/app/graphql/ee/types/issues/negated_issue_filter_input_type.rb'
- 'ee/app/graphql/ee/types/merge_request_type.rb'
- 'ee/app/graphql/ee/types/namespace_type.rb'
- 'ee/app/graphql/ee/types/project_type.rb'
# WIP: See https://gitlab.com/gitlab-org/gitlab/-/issues/220040
Rails/SaveBang:
Exclude:
......
......@@ -82,7 +82,7 @@ module Types
snippets: 'Snippets are',
container_registry: 'Container Registry is'
}.each do |feature, name_string|
field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true,
field "#{feature}_enabled", GraphQL::Types::Boolean, null: true,
description: "Indicates if #{name_string} enabled for the current user"
define_method "#{feature}_enabled" do
......
......@@ -105,7 +105,7 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do
describe 'with a single permission' do
let(:type) do
type_factory do |type|
type.field :name, GraphQL::STRING_TYPE, null: true, authorize: permission_single
type.field :name, GraphQL::Types::String, null: true, authorize: permission_single
end
end
......@@ -124,7 +124,7 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do
let(:type) do
permissions = permission_collection
type_factory do |type|
type.field :name, GraphQL::STRING_TYPE,
type.field :name, GraphQL::Types::String,
null: true,
authorize: permissions
end
......@@ -332,7 +332,7 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do
type_factory do |type|
type.graphql_name 'FakeIssueType'
type.authorize :read_issue
type.field :id, GraphQL::ID_TYPE, null: false
type.field :id, GraphQL::Types::ID, null: false
end
end
......
......@@ -15,7 +15,7 @@ RSpec.describe ::Mutations::BaseMutation do
context 'when argument is nullable and required' do
let(:mutation_class) do
Class.new(described_class) do
argument :foo, GraphQL::STRING_TYPE, required: :nullable
argument :foo, GraphQL::Types::String, required: :nullable
end
end
......@@ -35,7 +35,7 @@ RSpec.describe ::Mutations::BaseMutation do
context 'when argument is required and NOT nullable' do
let(:mutation_class) do
Class.new(described_class) do
argument :foo, GraphQL::STRING_TYPE, required: true
argument :foo, GraphQL::Types::String, required: true
end
end
......
......@@ -40,7 +40,7 @@ RSpec.describe Subscriptions::IssuableUpdated do
end
end
context 'when a GraphQL::ID_TYPE is provided' do
context 'when a GraphQL::Types::ID is provided' do
let(:issuable_id) { issue.to_gid.to_s }
it 'raises an exception' do
......
......@@ -7,7 +7,7 @@ RSpec.describe Gitlab::Graphql::CallsGitaly::FieldExtension, :request_store do
let(:field_args) { {} }
let(:owner) { fresh_object_type }
let(:field) do
::Types::BaseField.new(name: 'value', type: GraphQL::STRING_TYPE, null: true, owner: owner, **field_args)
::Types::BaseField.new(name: 'value', type: GraphQL::Types::String, null: true, owner: owner, **field_args)
end
def resolve_value
......
......@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Graphql::CopyFieldDescription do
Class.new(Types::BaseObject) do
graphql_name "TestType"
field :field_name, GraphQL::STRING_TYPE, null: true, description: 'Foo'
field :field_name, GraphQL::Types::String, null: true, description: 'Foo'
end
end
......
......@@ -6,8 +6,8 @@ RSpec.describe Gitlab::Graphql::MountMutation do
Class.new(Mutations::BaseMutation) do
graphql_name 'TestMutation'
argument :foo, GraphQL::STRING_TYPE, required: false
field :bar, GraphQL::STRING_TYPE, null: true
argument :foo, GraphQL::Types::String, required: false
field :bar, GraphQL::Types::String, null: true
end
end
......
......@@ -19,7 +19,7 @@ RSpec.describe Gitlab::Graphql::NegatableArguments do
it 'defines any arguments passed as block' do
test_resolver.negated do
argument :foo, GraphQL::STRING_TYPE, required: false
argument :foo, GraphQL::Types::String, required: false
end
expect(test_resolver.arguments['not'].type.arguments.keys).to match_array(['foo'])
......@@ -27,10 +27,10 @@ RSpec.describe Gitlab::Graphql::NegatableArguments do
it 'defines all arguments passed as block even if called multiple times' do
test_resolver.negated do
argument :foo, GraphQL::STRING_TYPE, required: false
argument :foo, GraphQL::Types::String, required: false
end
test_resolver.negated do
argument :bar, GraphQL::STRING_TYPE, required: false
argument :bar, GraphQL::Types::String, required: false
end
expect(test_resolver.arguments['not'].type.arguments.keys).to match_array(%w[foo bar])
......
......@@ -33,7 +33,7 @@ RSpec.describe ::Gitlab::Graphql::Pagination::Connections do
let(:node_type) do
Class.new(::GraphQL::Schema::Object) do
graphql_name 'Node'
field :value, GraphQL::INT_TYPE, null: false
field :value, GraphQL::Types::Int, null: false
end
end
......
......@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Graphql::Present::FieldExtension do
let(:owner) { fresh_object_type }
let(:field_name) { 'value' }
let(:field) do
::Types::BaseField.new(name: field_name, type: GraphQL::STRING_TYPE, null: true, owner: owner)
::Types::BaseField.new(name: field_name, type: GraphQL::Types::String, null: true, owner: owner)
end
let(:base_presenter) do
......@@ -38,7 +38,7 @@ RSpec.describe Gitlab::Graphql::Present::FieldExtension do
Module.new do
include ::Types::BaseInterface
field :interface_field, GraphQL::STRING_TYPE, null: true
field :interface_field, GraphQL::Types::String, null: true
end
end
......@@ -58,7 +58,7 @@ RSpec.describe Gitlab::Graphql::Present::FieldExtension do
end
it 'resolves the interface field using the implementation from the presenter' do
field = ::Types::BaseField.new(name: :interface_field, type: GraphQL::STRING_TYPE, null: true, owner: interface)
field = ::Types::BaseField.new(name: :interface_field, type: GraphQL::Types::String, null: true, owner: interface)
value = resolve_field(field, object, object_type: implementation)
expect(value).to eq 'made of concrete'
......@@ -67,7 +67,7 @@ RSpec.describe Gitlab::Graphql::Present::FieldExtension do
context 'when the implementation is inherited' do
it 'resolves the interface field using the implementation from the presenter' do
subclass = Class.new(implementation) { graphql_name 'Subclass' }
field = ::Types::BaseField.new(name: :interface_field, type: GraphQL::STRING_TYPE, null: true, owner: interface)
field = ::Types::BaseField.new(name: :interface_field, type: GraphQL::Types::String, null: true, owner: interface)
value = resolve_field(field, object, object_type: subclass)
expect(value).to eq 'made of concrete'
......@@ -79,8 +79,8 @@ RSpec.describe Gitlab::Graphql::Present::FieldExtension do
def parent
type = fresh_object_type('Parent')
type.present_using(provide_foo)
type.field :foo, ::GraphQL::INT_TYPE, null: true
type.field :value, ::GraphQL::STRING_TYPE, null: true
type.field :foo, ::GraphQL::Types::Int, null: true
type.field :value, ::GraphQL::Types::String, null: true
type
end
......@@ -88,7 +88,7 @@ RSpec.describe Gitlab::Graphql::Present::FieldExtension do
type = Class.new(parent)
type.graphql_name 'Child'
type.present_using(provide_bar)
type.field :bar, ::GraphQL::INT_TYPE, null: true
type.field :bar, ::GraphQL::Types::Int, null: true
type
end
......@@ -150,7 +150,7 @@ RSpec.describe Gitlab::Graphql::Present::FieldExtension do
let(:field) do
::Types::BaseField.new(
name: field_name,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: true,
owner: owner,
resolve: ->(obj, args, ctx) { 'Hello from a proc' }
......
......@@ -21,30 +21,30 @@ RSpec.describe Gitlab::Graphql::Queries do
let_it_be(:schema) do
author = Class.new(GraphQL::Schema::Object) do
graphql_name 'Author'
field :name, GraphQL::STRING_TYPE, null: true
field :handle, GraphQL::STRING_TYPE, null: false
field :verified, GraphQL::BOOLEAN_TYPE, null: false
field :name, GraphQL::Types::String, null: true
field :handle, GraphQL::Types::String, null: false
field :verified, GraphQL::Types::Boolean, null: false
end
post = Class.new(GraphQL::Schema::Object) do
graphql_name 'Post'
field :name, GraphQL::STRING_TYPE, null: false
field :title, GraphQL::STRING_TYPE, null: false
field :content, GraphQL::STRING_TYPE, null: true
field :name, GraphQL::Types::String, null: false
field :title, GraphQL::Types::String, null: false
field :content, GraphQL::Types::String, null: true
field :author, author, null: false
end
author.field :posts, [post], null: false do
argument :blog_title, GraphQL::STRING_TYPE, required: false
argument :blog_title, GraphQL::Types::String, required: false
end
blog = Class.new(GraphQL::Schema::Object) do
graphql_name 'Blog'
field :title, GraphQL::STRING_TYPE, null: false
field :description, GraphQL::STRING_TYPE, null: false
field :title, GraphQL::Types::String, null: false
field :description, GraphQL::Types::String, null: false
field :main_author, author, null: false
field :posts, [post], null: false
field :post, post, null: true do
argument :slug, GraphQL::STRING_TYPE, required: true
argument :slug, GraphQL::Types::String, required: true
end
end
......@@ -52,10 +52,10 @@ RSpec.describe Gitlab::Graphql::Queries do
query(Class.new(GraphQL::Schema::Object) do
graphql_name 'Query'
field :blog, blog, null: true do
argument :title, GraphQL::STRING_TYPE, required: true
argument :title, GraphQL::Types::String, required: true
end
field :post, post, null: true do
argument :slug, GraphQL::STRING_TYPE, required: true
argument :slug, GraphQL::Types::String, required: true
end
end)
end
......
......@@ -222,7 +222,7 @@ RSpec.describe RuboCop::Cop::Gitlab::MarkUsedFeatureFlags do
include_examples 'does not set any flags as used', 'field :solution'
include_examples 'does not set any flags as used', 'field :runners, Types::Ci::RunnerType.connection_type'
include_examples 'does not set any flags as used', 'field :runners, Types::Ci::RunnerType.connection_type, null: true, description: "hello world"'
include_examples 'does not set any flags as used', 'field :solution, type: GraphQL::STRING_TYPE, null: true, description: "URL to the vulnerabilitys details page."'
include_examples 'does not set any flags as used', 'field :solution, type: GraphQL::Types::String, null: true, description: "URL to the vulnerabilitys details page."'
end
describe "tracking of usage data metrics known events happens at the beginning of inspection" do
......
......@@ -13,7 +13,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
class FakeType < BaseObject
field :a_thing,
^^^^^^^^^^^^^^^ Please add a `description` property.
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false
end
end
......@@ -26,7 +26,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
class FakeType < BaseObject
field :a_thing,
^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false,
description: 'A descriptive description'
end
......@@ -39,7 +39,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
field :a_thing,
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false,
description: 'A descriptive description.'
end
......@@ -65,7 +65,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
class FakeType < BaseObject
argument :a_thing,
^^^^^^^^^^^^^^^^^^ Please add a `description` property.
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false
end
end
......@@ -78,7 +78,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
class FakeType < BaseObject
argument :a_thing,
^^^^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false,
description: 'Behold! A description'
end
......@@ -91,7 +91,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
argument :a_thing,
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false,
description: 'Behold! A description.'
end
......@@ -151,7 +151,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
class FakeType < BaseObject
field :a_thing,
^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false,
description: 'Behold! A description'
end
......@@ -162,7 +162,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
field :a_thing,
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false,
description: 'Behold! A description.'
end
......@@ -176,7 +176,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
class FakeType < BaseObject
field :a_thing,
^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false,
description: <<~DESC
Behold! A description
......@@ -189,7 +189,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
field :a_thing,
GraphQL::STRING_TYPE,
GraphQL::Types::String,
null: false,
description: <<~DESC
Behold! A description.
......
......@@ -24,7 +24,7 @@ RSpec.describe RuboCop::Cop::Graphql::IDType do
end
end
it 'does not add an offense for calls to #argument without GraphQL::ID_TYPE' do
it 'does not add an offense for calls to #argument without GraphQL::Types::ID' do
expect_no_offenses(<<~TYPE.strip)
argument :some_arg, ::Types::GlobalIDType[::Awardable], some: other, params: do_not_matter
TYPE
......
......@@ -32,7 +32,7 @@ RSpec.describe RuboCop::Cop::Graphql::JSONType do
it 'does not add an offense for other types' do
expect_no_offenses(<<~RUBY.strip)
class MyType
field :some_field, GraphQL::STRING_TYPE
field :some_field, GraphQL::Types::String
end
RUBY
end
......@@ -60,7 +60,7 @@ RSpec.describe RuboCop::Cop::Graphql::JSONType do
it 'does not add an offense for other types' do
expect_no_offenses(<<~RUBY.strip)
class MyType
argument :some_arg, GraphQL::STRING_TYPE
argument :some_arg, GraphQL::Types::String
end
RUBY
end
......
......@@ -654,7 +654,7 @@ module GraphqlHelpers
Class.new(Types::BaseObject) do
graphql_name 'TestType'
field :name, GraphQL::STRING_TYPE, null: true
field :name, GraphQL::Types::String, null: true
yield(self) if block_given?
end
......
......@@ -14,13 +14,13 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
let(:template) { Rails.root.join('tooling/graphql/docs/templates/default.md.haml') }
let(:field_description) { 'List of objects.' }
let(:type) { ::GraphQL::INT_TYPE }
let(:type) { ::GraphQL::Types::Int }
let(:query_type) do
Class.new(Types::BaseObject) { graphql_name 'Query' }.tap do |t|
# this keeps type and field_description in scope.
t.field :foo, type, null: true, description: field_description do
argument :id, GraphQL::ID_TYPE, required: false, description: 'ID of the object.'
argument :id, GraphQL::Types::ID, required: false, description: 'ID of the object.'
end
end
end
......@@ -73,7 +73,7 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
Class.new(Types::BaseObject) do
graphql_name 'ArrayTest'
field :foo, [GraphQL::STRING_TYPE], null: false, description: 'A description.'
field :foo, [GraphQL::Types::String], null: false, description: 'A description.'
end
end
......@@ -129,8 +129,8 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
Class.new(Types::BaseObject) do
graphql_name 'OrderingTest'
field :foo, GraphQL::STRING_TYPE, null: false, description: 'A description of foo field.'
field :bar, GraphQL::STRING_TYPE, null: false, description: 'A description of bar field.'
field :foo, GraphQL::Types::String, null: false, description: 'A description of foo field.'
field :bar, GraphQL::Types::String, null: false, description: 'A description of bar field.'
end
end
......@@ -154,7 +154,7 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
let(:type) do
wibble = Class.new(::Types::BaseObject) do
graphql_name 'Wibble'
field :x, ::GraphQL::INT_TYPE, null: false
field :x, ::GraphQL::Types::Int, null: false
end
Class.new(Types::BaseObject) do
......@@ -162,16 +162,16 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
description 'Testing doc refs'
field :foo,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
description: 'The foo.',
see: { 'A list of foos' => 'https://example.com/foos' }
field :bar,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
description: 'The bar.',
see: { 'A list of bars' => 'https://example.com/bars' } do
argument :barity, ::GraphQL::INT_TYPE, required: false, description: '?'
argument :barity, ::GraphQL::Types::Int, required: false, description: '?'
end
field :wibbles,
type: wibble.connection_type,
......@@ -220,10 +220,10 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
description 'A thing we used to use, but no longer support'
field :foo,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
description: 'A description.' do
argument :foo_arg, GraphQL::STRING_TYPE,
argument :foo_arg, GraphQL::Types::String,
required: false,
description: 'The argument.',
deprecated: { reason: 'Bad argument', milestone: '101.2' }
......@@ -257,19 +257,19 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
description 'A thing we used to use, but no longer support'
field :foo,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
deprecated: { reason: 'This is deprecated', milestone: '1.10' },
description: 'A description.'
field :foo_with_args,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
deprecated: { reason: 'Do not use', milestone: '1.10', replacement: 'X.y' },
description: 'A description.' do
argument :arg, GraphQL::INT_TYPE, required: false, description: 'Argity'
argument :arg, GraphQL::Types::Int, required: false, description: 'Argity'
end
field :bar,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: false,
description: 'A description.',
deprecated: {
......@@ -328,7 +328,7 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
)
end
let(:type) { ::GraphQL::INT_TYPE }
let(:type) { ::GraphQL::Types::Int }
let(:section) do
<<~DOC
### `Query.bar`
......@@ -453,12 +453,12 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
}
mutation.field :everything,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: true,
description: 'What we made prettier.'
mutation.field :omnis,
type: GraphQL::STRING_TYPE,
type: GraphQL::Types::String,
null: true,
description: 'What we made prettier.',
deprecated: {
......@@ -516,7 +516,7 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
let(:type) do
Class.new(::Types::BaseObject) do
graphql_name 'Foo'
field :wibble, type: ::GraphQL::INT_TYPE, null: true do
field :wibble, type: ::GraphQL::Types::Int, null: true do
argument :date_range,
type: ::Types::TimeframeInputType,
required: true,
......@@ -547,10 +547,10 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
let(:type) do
user = Class.new(::Types::BaseObject)
user.graphql_name 'User'
user.field :user_field, ::GraphQL::STRING_TYPE, null: true
user.field :user_field, ::GraphQL::Types::String, null: true
group = Class.new(::Types::BaseObject)
group.graphql_name 'Group'
group.field :group_field, ::GraphQL::STRING_TYPE, null: true
group.field :group_field, ::GraphQL::Types::String, null: true
union = Class.new(::Types::BaseUnion)
union.graphql_name 'UserOrGroup'
......@@ -561,7 +561,7 @@ RSpec.describe Tooling::Graphql::Docs::Renderer do
interface.include(::Types::BaseInterface)
interface.graphql_name 'Flying'
interface.description 'Something that can fly.'
interface.field :flight_speed, GraphQL::INT_TYPE, null: true, description: 'Speed in mph.'
interface.field :flight_speed, GraphQL::Types::Int, null: true, description: 'Speed in mph.'
african_swallow = Class.new(::Types::BaseObject)
african_swallow.graphql_name 'AfricanSwallow'
......
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