diff --git a/ee/spec/factories/dast/profile_schedule_input_type.rb b/ee/spec/factories/dast/profile_schedule_input_type.rb index 2fd351dd394157bc0542df8128013c52bb728384..a74fbb81b0a7aca22dd50cfd8005ccb135983c37 100644 --- a/ee/spec/factories/dast/profile_schedule_input_type.rb +++ b/ee/spec/factories/dast/profile_schedule_input_type.rb @@ -15,8 +15,11 @@ startsAt: Time.now, cadence: { unit: %w(day month year week).sample, duration: 1 } } - ::Types::Dast::ProfileScheduleInputType.to_graphql - initialize_with { ::Types::Dast::ProfileScheduleInputType.new(arguments, defaults_used: [], context: context) } + initialize_with do + ruby_kwargs = arguments.transform_keys { |key| key.to_s.underscore.to_sym } + + ::Types::Dast::ProfileScheduleInputType.new(ruby_kwargs: ruby_kwargs, defaults_used: [], context: context) + end end end diff --git a/ee/spec/graphql/mutations/dast/profiles/update_spec.rb b/ee/spec/graphql/mutations/dast/profiles/update_spec.rb index ef3224fd366df53be95bdf586fe14a976a374807..7c24fb7117cdaa2b1e567c900a9d8a86c905987e 100644 --- a/ee/spec/graphql/mutations/dast/profiles/update_spec.rb +++ b/ee/spec/graphql/mutations/dast/profiles/update_spec.rb @@ -123,6 +123,7 @@ context 'when associated dast profile schedule is not present' do context 'when dast_profile_schedule param is present' do let(:new_dast_profile_schedule) { create(:dast_profile_schedule_input_type) } + let(:new_dast_profile_schedule_h) { new_dast_profile_schedule.to_h } subject do mutation.resolve(**params.merge(dast_profile_schedule: new_dast_profile_schedule)) @@ -134,10 +135,10 @@ new_schedule = dast_profile.reload.dast_profile_schedule aggregate_failures do - expect(new_schedule.timezone).to eq(new_dast_profile_schedule[:timezone]) - expect(new_schedule.starts_at.to_i).to eq(new_dast_profile_schedule[:starts_at].to_i) - expect(new_schedule.cadence[:duration]).to eq(new_dast_profile_schedule[:cadence].duration) - expect(new_schedule.cadence[:unit]).to eq(new_dast_profile_schedule[:cadence].unit) + expect(new_schedule.timezone).to eq(new_dast_profile_schedule_h[:timezone]) + expect(new_schedule.starts_at.to_i).to eq(new_dast_profile_schedule_h[:starts_at].to_i) + expect(new_schedule.cadence[:duration]).to eq(new_dast_profile_schedule_h[:cadence][:duration]) + expect(new_schedule.cadence[:unit]).to eq(new_dast_profile_schedule_h[:cadence][:unit]) end end end diff --git a/ee/spec/graphql/resolvers/epics_resolver_spec.rb b/ee/spec/graphql/resolvers/epics_resolver_spec.rb index 40107cec3ceb2e7f49bbb9618c425ee04ab97782..1961d2abd56d543aa13a6e4c3472ea3810ead4b5 100644 --- a/ee/spec/graphql/resolvers/epics_resolver_spec.rb +++ b/ee/spec/graphql/resolvers/epics_resolver_spec.rb @@ -42,7 +42,7 @@ it 'does not inflate the complexity' do field = Types::BaseField.new(name: 'test', type: GraphQL::Types::String, resolver_class: described_class, null: false, max_page_size: 100) - expect(field.to_graphql.complexity.call({}, { iid: [epic1.iid] }, 5)).to eq 6 + expect(field.complexity.call({}, { iid: [epic1.iid] }, 5)).to eq 6 end end @@ -59,8 +59,8 @@ it 'increases the complexity based on child_complexity and number of iids' do field = Types::BaseField.new(name: 'test', type: GraphQL::Types::String, resolver_class: described_class, null: false, max_page_size: 100) - expect(field.to_graphql.complexity.call({}, { iids: [epic1.iid] }, 5)).to eq 6 - expect(field.to_graphql.complexity.call({}, { iids: [epic1.iid, epic2.iid] }, 5)).to eq 11 + expect(field.complexity.call({}, { iids: [epic1.iid] }, 5)).to eq 6 + expect(field.complexity.call({}, { iids: [epic1.iid, epic2.iid] }, 5)).to eq 11 end end diff --git a/spec/graphql/resolvers/base_resolver_spec.rb b/spec/graphql/resolvers/base_resolver_spec.rb index d77a0b6242e54988fdb3656c64cef970197adc6e..39b00c14161a11aa76ab458483ff17cd43e8cb64 100644 --- a/spec/graphql/resolvers/base_resolver_spec.rb +++ b/spec/graphql/resolvers/base_resolver_spec.rb @@ -239,16 +239,16 @@ def resolve(**args) it 'increases complexity based on arguments' do field = Types::BaseField.new(name: 'test', type: GraphQL::Types::String.connection_type, resolver_class: described_class, null: false, max_page_size: 1) - expect(field.to_graphql.complexity.call({}, { sort: 'foo' }, 1)).to eq 3 - expect(field.to_graphql.complexity.call({}, { search: 'foo' }, 1)).to eq 7 + expect(field.complexity.call({}, { sort: 'foo' }, 1)).to eq 3 + expect(field.complexity.call({}, { search: 'foo' }, 1)).to eq 7 end it 'does not increase complexity when filtering by iids' do field = Types::BaseField.new(name: 'test', type: GraphQL::Types::String.connection_type, resolver_class: described_class, null: false, max_page_size: 100) - expect(field.to_graphql.complexity.call({}, { sort: 'foo' }, 1)).to eq 6 - expect(field.to_graphql.complexity.call({}, { sort: 'foo', iid: 1 }, 1)).to eq 3 - expect(field.to_graphql.complexity.call({}, { sort: 'foo', iids: [1, 2, 3] }, 1)).to eq 3 + expect(field.complexity.call({}, { sort: 'foo' }, 1)).to eq 6 + expect(field.complexity.call({}, { sort: 'foo', iid: 1 }, 1)).to eq 3 + expect(field.complexity.call({}, { sort: 'foo', iids: [1, 2, 3] }, 1)).to eq 3 end end diff --git a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb index 38f5a6449850363b47807cb020c1dd308774b9c4..4c4aa4f53e1339a888e54beb85f064f49d177b60 100644 --- a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb +++ b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb @@ -106,9 +106,9 @@ def resolve(**args) it 'increases field complexity based on arguments' do field = Types::BaseField.new(name: 'test', type: GraphQL::Types::String, resolver_class: resolver, null: false, max_page_size: 1) - expect(field.to_graphql.complexity.call({}, {}, 1)).to eq 2 - expect(field.to_graphql.complexity.call({}, { sha: 'foo' }, 1)).to eq 4 - expect(field.to_graphql.complexity.call({}, { sha: 'ref' }, 1)).to eq 4 + expect(field.complexity.call({}, {}, 1)).to eq 2 + expect(field.complexity.call({}, { sha: 'foo' }, 1)).to eq 4 + expect(field.complexity.call({}, { sha: 'ref' }, 1)).to eq 4 end def resolve_pipelines(args = {}, context = { current_user: current_user }) diff --git a/spec/graphql/resolvers/issues_resolver_spec.rb b/spec/graphql/resolvers/issues_resolver_spec.rb index dc717b113c170959b7dbbde7e79ae34ec44ca354..326c105a358a89698081f53c460cb221febf0afb 100644 --- a/spec/graphql/resolvers/issues_resolver_spec.rb +++ b/spec/graphql/resolvers/issues_resolver_spec.rb @@ -618,8 +618,8 @@ it 'increases field complexity based on arguments' do field = Types::BaseField.new(name: 'test', type: GraphQL::Types::String.connection_type, resolver_class: described_class, null: false, max_page_size: 100) - expect(field.to_graphql.complexity.call({}, {}, 1)).to eq 4 - expect(field.to_graphql.complexity.call({}, { labelName: 'foo' }, 1)).to eq 8 + expect(field.complexity.call({}, {}, 1)).to eq 4 + expect(field.complexity.call({}, { labelName: 'foo' }, 1)).to eq 8 end def create_issue_with_severity(project, severity:) diff --git a/spec/graphql/resolvers/namespace_projects_resolver_spec.rb b/spec/graphql/resolvers/namespace_projects_resolver_spec.rb index b1f50a4a4a5ce0bdb036fd548f80466fbcc76855..eb4d0ab6f37a93a78b5b1daeb1e692fa28825d82 100644 --- a/spec/graphql/resolvers/namespace_projects_resolver_spec.rb +++ b/spec/graphql/resolvers/namespace_projects_resolver_spec.rb @@ -147,8 +147,8 @@ it 'has an high complexity regardless of arguments' do field = Types::BaseField.new(name: 'test', type: GraphQL::Types::String.connection_type, resolver_class: described_class, null: false, max_page_size: 100) - expect(field.to_graphql.complexity.call({}, {}, 1)).to eq 24 - expect(field.to_graphql.complexity.call({}, { include_subgroups: true }, 1)).to eq 24 + expect(field.complexity.call({}, {}, 1)).to eq 24 + expect(field.complexity.call({}, { include_subgroups: true }, 1)).to eq 24 end def resolve_projects(args = { include_subgroups: false, sort: nil, search: nil, ids: nil }, context = { current_user: current_user }) diff --git a/spec/graphql/resolvers/project_resolver_spec.rb b/spec/graphql/resolvers/project_resolver_spec.rb index cd3fdc788e6402c603ee40d4c3d7b90034d85f23..dec9d4701e1fb449cdfe2fb3744c7707d40fd87e 100644 --- a/spec/graphql/resolvers/project_resolver_spec.rb +++ b/spec/graphql/resolvers/project_resolver_spec.rb @@ -36,8 +36,8 @@ field1 = Types::BaseField.new(name: 'test', type: GraphQL::Types::String, resolver_class: described_class, null: false, max_page_size: 100) field2 = Types::BaseField.new(name: 'test', type: GraphQL::Types::String, resolver_class: described_class, null: false, max_page_size: 1) - expect(field1.to_graphql.complexity.call({}, {}, 1)).to eq 2 - expect(field2.to_graphql.complexity.call({}, {}, 1)).to eq 2 + expect(field1.complexity.call({}, {}, 1)).to eq 2 + expect(field2.complexity.call({}, {}, 1)).to eq 2 end def resolve_project(full_path) diff --git a/spec/graphql/types/base_enum_spec.rb b/spec/graphql/types/base_enum_spec.rb index 64524f3ffcd816e5a29955beff44f55350c5338a..65a345052c74cffe4ee32ed65dd0b38562d62ba6 100644 --- a/spec/graphql/types/base_enum_spec.rb +++ b/spec/graphql/types/base_enum_spec.rb @@ -136,7 +136,7 @@ def subject(args = {}) value 'TEST_VALUE', **args end - enum.to_graphql.values['TEST_VALUE'] + enum.values['TEST_VALUE'] end end end diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index 31d07f701e8a8dd93bcdfa33aef9cb0382a41900..9d02f061435ba0ffc000d2616d7213235a819af9 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -19,7 +19,7 @@ def self.complexity_multiplier(args) it 'defaults to 1' do field = described_class.new(name: 'test', type: GraphQL::Types::String, null: true) - expect(field.to_graphql.complexity).to eq 1 + expect(field.complexity).to eq 1 end describe '#base_complexity' do @@ -43,7 +43,7 @@ def self.complexity_multiplier(args) it 'has specified value' do field = described_class.new(name: 'test', type: GraphQL::Types::String, null: true, complexity: 12) - expect(field.to_graphql.complexity).to eq 12 + expect(field.complexity).to eq 12 end context 'when field has a resolver' do @@ -51,7 +51,7 @@ def self.complexity_multiplier(args) let(:field) { described_class.new(name: 'test', type: GraphQL::Types::String.connection_type, resolver_class: resolver, complexity: 2, max_page_size: 100, null: true) } it 'uses this complexity' do - expect(field.to_graphql.complexity).to eq 2 + expect(field.complexity).to eq 2 end end @@ -59,13 +59,13 @@ def self.complexity_multiplier(args) let(:field) { described_class.new(name: 'test', type: GraphQL::Types::String.connection_type, resolver_class: resolver, max_page_size: 100, null: true) } it 'sets complexity depending on arguments for resolvers' do - expect(field.to_graphql.complexity.call({}, {}, 2)).to eq 4 - expect(field.to_graphql.complexity.call({}, { first: 50 }, 2)).to eq 3 + expect(field.complexity.call({}, {}, 2)).to eq 4 + expect(field.complexity.call({}, { first: 50 }, 2)).to eq 3 end it 'sets complexity depending on number load limits for resolvers' do - expect(field.to_graphql.complexity.call({}, { first: 1 }, 2)).to eq 2 - expect(field.to_graphql.complexity.call({}, { first: 1, foo: true }, 2)).to eq 4 + expect(field.complexity.call({}, { first: 1 }, 2)).to eq 2 + expect(field.complexity.call({}, { first: 1, foo: true }, 2)).to eq 4 end end @@ -73,8 +73,8 @@ def self.complexity_multiplier(args) it 'sets complexity as normal' do field = described_class.new(name: 'test', type: GraphQL::Types::String, resolver_class: resolver, max_page_size: 100, null: true) - expect(field.to_graphql.complexity.call({}, {}, 2)).to eq 2 - expect(field.to_graphql.complexity.call({}, { first: 50 }, 2)).to eq 2 + expect(field.complexity.call({}, {}, 2)).to eq 2 + expect(field.complexity.call({}, { first: 50 }, 2)).to eq 2 end end end @@ -84,9 +84,9 @@ def self.complexity_multiplier(args) it 'adds 1 if true' do with_gitaly_field = described_class.new(name: 'test', type: GraphQL::Types::String, resolver_class: resolver, null: true, calls_gitaly: true) without_gitaly_field = described_class.new(name: 'test', type: GraphQL::Types::String, resolver_class: resolver, null: true) - base_result = without_gitaly_field.to_graphql.complexity.call({}, {}, 2) + base_result = without_gitaly_field.complexity.call({}, {}, 2) - expect(with_gitaly_field.to_graphql.complexity.call({}, {}, 2)).to eq base_result + 1 + expect(with_gitaly_field.complexity.call({}, {}, 2)).to eq base_result + 1 end end @@ -94,7 +94,7 @@ def self.complexity_multiplier(args) it 'adds 1 if true' do field = described_class.new(name: 'test', type: GraphQL::Types::String, null: true, calls_gitaly: true) - expect(field.to_graphql.complexity).to eq 2 + expect(field.complexity).to eq 2 end end @@ -108,14 +108,14 @@ def self.complexity_multiplier(args) it 'has complexity set to that constant' do field = described_class.new(name: 'test', type: GraphQL::Types::String, null: true, complexity: 12) - expect(field.to_graphql.complexity).to eq 12 + expect(field.complexity).to eq 12 end it 'does not raise an error even with Gitaly calls' do allow(Gitlab::GitalyClient).to receive(:get_request_count).and_return([0, 1]) field = described_class.new(name: 'test', type: GraphQL::Types::String, null: true, complexity: 12) - expect(field.to_graphql.complexity).to eq 12 + expect(field.complexity).to eq 12 end end end diff --git a/spec/graphql/types/global_id_type_spec.rb b/spec/graphql/types/global_id_type_spec.rb index f9391efdf081ffabc63e1825b90ee8c921d0d282..8df92c818fc276b696f090cc78b8d901eb1bb7a9 100644 --- a/spec/graphql/types/global_id_type_spec.rb +++ b/spec/graphql/types/global_id_type_spec.rb @@ -11,7 +11,7 @@ let(:gid) { project.to_global_id } it 'is has the correct name' do - expect(described_class.to_graphql.name).to eq('GlobalID') + expect(described_class.graphql_name).to eq('GlobalID') end describe '.coerce_result' do @@ -63,7 +63,7 @@ let(:type) { ::Types::GlobalIDType[::Project] } it 'is has the correct name' do - expect(type.to_graphql.name).to eq('ProjectID') + expect(type.graphql_name).to eq('ProjectID') end context 'the GID is appropriate' do @@ -126,7 +126,7 @@ let(:deprecating_gid) { Gitlab::GlobalId.build(model_name: 'Issue', id: issue.id) } it 'appends the description with a deprecation notice for the old Global ID' do - expect(type.to_graphql.description).to include('The older format `"gid://gitlab/OldIssue/1"` was deprecated in 10.0') + expect(type.description).to include('The older format `"gid://gitlab/OldIssue/1"` was deprecated in 10.0') end describe 'coercing input against the type (parsing the Global ID string when supplied as an argument)' do @@ -242,7 +242,7 @@ let(:type) { ::Types::GlobalIDType[::Ci::Build] } it 'is has a valid GraphQL identifier for a name' do - expect(type.to_graphql.name).to eq('CiBuildID') + expect(type.graphql_name).to eq('CiBuildID') end end diff --git a/spec/lib/gitlab/graphql/markdown_field_spec.rb b/spec/lib/gitlab/graphql/markdown_field_spec.rb index c2253811e916380495cc3b9e3af433f6c6d65424..ed3f19d8cf235418901a2b1111d7b11a606ae48f 100644 --- a/spec/lib/gitlab/graphql/markdown_field_spec.rb +++ b/spec/lib/gitlab/graphql/markdown_field_spec.rb @@ -11,7 +11,7 @@ expect(field.name).to eq('testHtml') expect(field.description).to eq('The GitLab Flavored Markdown rendering of `hello`') expect(field.type).to eq(GraphQL::Types::String) - expect(field.to_graphql.complexity).to eq(5) + expect(field.complexity).to eq(5) end context 'developer warnings' do @@ -43,7 +43,7 @@ let(:field) { type_class.fields['noteHtml'] } it 'renders markdown from the same property as the field name without the `_html` suffix' do - expect(field.to_graphql.resolve(type_instance, {}, context)).to eq(expected_markdown) + expect(field.resolve(type_instance, {}, context)).to eq(expected_markdown) end context 'when a `method` argument is passed' do @@ -51,7 +51,7 @@ let(:field) { type_class.fields['testHtml'] } it 'renders markdown from a specific property' do - expect(field.to_graphql.resolve(type_instance, {}, context)).to eq(expected_markdown) + expect(field.resolve(type_instance, {}, context)).to eq(expected_markdown) end end @@ -62,21 +62,21 @@ let(:note) { build(:note, note: "Referencing #{issue.to_reference(full: true)}") } it 'renders markdown correctly' do - expect(field.to_graphql.resolve(type_instance, {}, context)).to include(issue_path(issue)) + expect(field.resolve(type_instance, {}, context)).to include(issue_path(issue)) end context 'when the issue is not publicly accessible' do let_it_be(:project) { create(:project, :private) } it 'hides the references from users that are not allowed to see the reference' do - expect(field.to_graphql.resolve(type_instance, {}, context)).not_to include(issue_path(issue)) + expect(field.resolve(type_instance, {}, context)).not_to include(issue_path(issue)) end it 'shows the reference to users that are allowed to see it' do context = GraphQL::Query::Context.new(query: query, values: { current_user: project.first_owner }, object: nil) type_instance = type_class.authorized_new(note, context) - expect(field.to_graphql.resolve(type_instance, {}, context)).to include(issue_path(issue)) + expect(field.resolve(type_instance, {}, context)).to include(issue_path(issue)) end end end diff --git a/spec/lib/gitlab/graphql/mount_mutation_spec.rb b/spec/lib/gitlab/graphql/mount_mutation_spec.rb index fe25e923506043be30508d401e8cf80e41c514c9..09fd9eac714242f3a901f85a8e608a9e678bf24a 100644 --- a/spec/lib/gitlab/graphql/mount_mutation_spec.rb +++ b/spec/lib/gitlab/graphql/mount_mutation_spec.rb @@ -17,7 +17,7 @@ f.mount_mutation(mutation) end - mutation_type.get_field('testMutation').to_graphql + mutation_type.get_field('testMutation') end it 'mounts a mutation' do @@ -31,7 +31,7 @@ f.mount_aliased_mutation('MyAlias', mutation) end - mutation_type.get_field('myAlias').to_graphql + mutation_type.get_field('myAlias') end it 'mounts a mutation' do @@ -43,11 +43,11 @@ end it 'has a correct type' do - expect(field.type.name).to eq('MyAliasPayload') + expect(field.type.to_type_signature).to eq('MyAliasPayload') end it 'has a correct input argument' do - expect(field.arguments['input'].type.unwrap.name).to eq('MyAliasInput') + expect(field.arguments['input'].type.unwrap.to_type_signature).to eq('MyAliasInput') end end