diff --git a/Gemfile b/Gemfile index 8c8802e4435873907d8f652707dce99d58f9eb4d..b2734269a8c0abe6a8c9755cfa835dde68eedcfe 100644 --- a/Gemfile +++ b/Gemfile @@ -87,7 +87,7 @@ gem 'grape-entity', '~> 0.7.1' gem 'rack-cors', '~> 1.0.6', require: 'rack/cors' # GraphQL API -gem 'graphql', '~> 1.9.19' +gem 'graphql', '~> 1.10.5' # NOTE: graphiql-rails v1.5+ doesn't work: https://gitlab.com/gitlab-org/gitlab/issues/31771 # TODO: remove app/views/graphiql/rails/editors/show.html.erb when https://github.com/rmosolgo/graphiql-rails/pull/71 is released: # https://gitlab.com/gitlab-org/gitlab/issues/31747 diff --git a/Gemfile.lock b/Gemfile.lock index 3bbe3020b70c2e1b579bb9e54dab87b51bcad974..e96a38ccf22ff0dbb4b56342a6def239b2e4b920 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -456,7 +456,7 @@ GEM graphiql-rails (1.4.10) railties sprockets-rails - graphql (1.9.19) + graphql (1.10.5) graphql-docs (1.6.0) commonmarker (~> 0.16) escape_utils (~> 1.2) @@ -1252,7 +1252,7 @@ DEPENDENCIES grape-path-helpers (~> 1.2) grape_logging (~> 1.7) graphiql-rails (~> 1.4.10) - graphql (~> 1.9.19) + graphql (~> 1.10.5) graphql-docs (~> 1.6.0) grpc (~> 1.24.0) gssapi diff --git a/ee/spec/graphql/types/design_management/design_at_version_type_spec.rb b/ee/spec/graphql/types/design_management/design_at_version_type_spec.rb index 5865015beeccf5f714f33bcc2ca710cf981c48ea..1453d73d59c7fef617c3eead7576c0b137b2f7b2 100644 --- a/ee/spec/graphql/types/design_management/design_at_version_type_spec.rb +++ b/ee/spec/graphql/types/design_management/design_at_version_type_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' -# describe GitlabSchema.types['DesignAtVersion'] do -# This not available on the schema until we mount it somewhere -describe ::Types::DesignManagement::DesignAtVersionType.to_graphql do +describe GitlabSchema.types['DesignAtVersion'] do it_behaves_like 'a GraphQL type with design fields' do let(:extra_design_fields) { %i[version design] } let_it_be(:design) { create(:design, :with_versions) } diff --git a/ee/spec/graphql/types/design_management_type_spec.rb b/ee/spec/graphql/types/design_management_type_spec.rb index 9cff40f425ef671cb853538ca91221dc11445e08..a6204f20f23a1be002e23583636c3467a4de6c95 100644 --- a/ee/spec/graphql/types/design_management_type_spec.rb +++ b/ee/spec/graphql/types/design_management_type_spec.rb @@ -3,5 +3,5 @@ require 'spec_helper' describe GitlabSchema.types['DesignManagement'] do - it { is_expected.to have_graphql_fields(:version, :design_at_version) } + it { expect(described_class).to have_graphql_fields(:version, :design_at_version) } end diff --git a/ee/spec/graphql/types/epic_type_spec.rb b/ee/spec/graphql/types/epic_type_spec.rb index e90230b732a869e43f6898507430ad027922ae1b..8af54dcd17bfcfb9f98df94eb288e85d627fdfa0 100644 --- a/ee/spec/graphql/types/epic_type_spec.rb +++ b/ee/spec/graphql/types/epic_type_spec.rb @@ -23,7 +23,7 @@ it { expect(described_class).to have_graphql_fields(fields) } - it { is_expected.to have_graphql_field(:subscribed, complexity: 5) } + it { expect(described_class).to have_graphql_field(:subscribed, complexity: 5) } - it { is_expected.to have_graphql_field(:participants, complexity: 5) } + it { expect(described_class).to have_graphql_field(:participants, complexity: 5) } end diff --git a/ee/spec/graphql/types/project_type_spec.rb b/ee/spec/graphql/types/project_type_spec.rb index c307574d3a6917d9ed7c5889d50decc918e8fdd5..fd85d026be26c16c41c0e9ca93ae2dedf4c408e7 100644 --- a/ee/spec/graphql/types/project_type_spec.rb +++ b/ee/spec/graphql/types/project_type_spec.rb @@ -6,7 +6,7 @@ it 'includes the ee specific fields' do expected_fields = %w[service_desk_enabled service_desk_address vulnerabilities] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end describe 'vulnerabilities' do diff --git a/ee/spec/graphql/types/query_type_spec.rb b/ee/spec/graphql/types/query_type_spec.rb index f85e44c7b6e45fb33cc0933a98cd1ed1249b12c4..32b56a61f0bbfae1ba7bc2be70bdcb7425eee5c8 100644 --- a/ee/spec/graphql/types/query_type_spec.rb +++ b/ee/spec/graphql/types/query_type_spec.rb @@ -4,6 +4,6 @@ describe GitlabSchema.types['Query'] do it do - is_expected.to have_graphql_fields(:design_management).at_least + expect(described_class).to have_graphql_fields(:design_management).at_least end end diff --git a/ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb b/ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb index 0472ece5c28fd459f306b830fe56fe41501d5dc0..a7a7b267990e5bebd1b64ea0b680ee7e80ab233c 100644 --- a/ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb +++ b/ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb @@ -90,7 +90,7 @@ def mutation_response end it_behaves_like 'a mutation that returns top-level errors', - errors: ['Variable epicTreeReorderInput of type EpicTreeReorderInput! was provided invalid value for moved.relativePosition (Expected "invalid" to be one of: before, after)'] + errors: ['Variable $epicTreeReorderInput of type EpicTreeReorderInput! was provided invalid value for moved.relativePosition (Expected "invalid" to be one of: before, after)'] end context 'when object being moved is not supported type' do diff --git a/ee/spec/requests/api/graphql/mutations/issues/set_weight_spec.rb b/ee/spec/requests/api/graphql/mutations/issues/set_weight_spec.rb index 1cf7ea2cce519b6d63b619a88cfbba38d57d21e6..b3ec1f39e2dfe624b21b1ec7bc6f556223418da4 100644 --- a/ee/spec/requests/api/graphql/mutations/issues/set_weight_spec.rb +++ b/ee/spec/requests/api/graphql/mutations/issues/set_weight_spec.rb @@ -55,7 +55,7 @@ def mutation_response let(:input) { { weight: "2" } } it 'raises invalid value error' do - error = "Variable issueSetWeightInput of type IssueSetWeightInput! was provided "\ + error = "Variable $issueSetWeightInput of type IssueSetWeightInput! was provided "\ "invalid value for weight (Could not coerce value \"#{input[:weight]}\" to Int)" post_graphql_mutation(mutation, current_user: current_user) diff --git a/ee/spec/support/shared_examples/graphql/design_fields_shared_examples.rb b/ee/spec/support/shared_examples/graphql/design_fields_shared_examples.rb index f5e77b2c8961eebd874b2cde3ad659b10547b1b9..029d7e677da910e7af2135dd77a12d71a805771e 100644 --- a/ee/spec/support/shared_examples/graphql/design_fields_shared_examples.rb +++ b/ee/spec/support/shared_examples/graphql/design_fields_shared_examples.rb @@ -22,7 +22,7 @@ notes_count ] + extra_design_fields - is_expected.to have_graphql_fields(*expected_fields).only + expect(described_class).to have_graphql_fields(*expected_fields).only end describe '#image' do @@ -41,7 +41,7 @@ end it 'resolves to the design image URL' do - image = field.resolve(instance, args, context) + image = field.resolve_field(instance, args, context) sha = design.versions.first.sha url = ::Gitlab::Routing.url_helpers.project_design_management_designs_raw_image_url(design.project, design, sha) @@ -67,10 +67,10 @@ # = 10 expect(instance).not_to eq(instance_b) # preload designs themselves. expect do - image_a = field.resolve(instance, args, context) - image_b = field.resolve(instance, args, context) - image_c = field.resolve(instance_b, args, context) - image_d = field.resolve(instance_b, args, context) + image_a = field.resolve_field(instance, args, context) + image_b = field.resolve_field(instance, args, context) + image_c = field.resolve_field(instance_b, args, context) + image_d = field.resolve_field(instance_b, args, context) expect(image_a).to eq(image_b) expect(image_c).not_to eq(image_b) expect(image_c).to eq(image_d) diff --git a/spec/graphql/features/authorization_spec.rb b/spec/graphql/features/authorization_spec.rb index 44f47e6c7396e93e0595ec8f0c497cef0a9de146..4f54695e5bef6127fadcefdf7dafba7a4e3e82d4 100644 --- a/spec/graphql/features/authorization_spec.rb +++ b/spec/graphql/features/authorization_spec.rb @@ -9,7 +9,7 @@ let(:permission_single) { :foo } let(:permission_collection) { [:foo, :bar] } let(:test_object) { double(name: 'My name') } - let(:query_string) { '{ item() { name } }' } + let(:query_string) { '{ item { name } }' } let(:result) { execute_query(query_type)['data'] } subject { result['item'] } @@ -177,7 +177,7 @@ end describe 'type authorizations when applied to a relay connection' do - let(:query_string) { '{ item() { edges { node { name } } } }' } + let(:query_string) { '{ item { edges { node { name } } } }' } let(:second_test_object) { double(name: 'Second thing') } let(:type) do diff --git a/spec/graphql/features/feature_flag_spec.rb b/spec/graphql/features/feature_flag_spec.rb index 13b1e472fab15a65fa50d1dbd7d3ae6031197da2..51914cf0ca8f7663b82840db9ce19d35155076c4 100644 --- a/spec/graphql/features/feature_flag_spec.rb +++ b/spec/graphql/features/feature_flag_spec.rb @@ -9,7 +9,7 @@ let(:feature_flag) { 'test_feature' } let(:test_object) { double(name: 'My name') } - let(:query_string) { '{ item() { name } }' } + let(:query_string) { '{ item { name } }' } let(:result) { execute_query(query_type)['data'] } subject { result } diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb index d0eb0475879af73c3b9afa0ccc9bbef985b734dd..bd22458355c3d4520161e1123b9661acfd520dc3 100644 --- a/spec/graphql/gitlab_schema_spec.rb +++ b/spec/graphql/gitlab_schema_spec.rb @@ -27,11 +27,11 @@ end it 'has the base mutation' do - expect(described_class.mutation).to eq(::Types::MutationType.to_graphql) + expect(described_class.mutation).to eq(::Types::MutationType) end it 'has the base query' do - expect(described_class.query).to eq(::Types::QueryType.to_graphql) + expect(described_class.query).to eq(::Types::QueryType) end it 'paginates active record relations using `Connections::Keyset::Connection`' do diff --git a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb index 5663a3d7195034cdf4c8dc7875088ce6b6e9c9ce..de5ece3b74956b07ede105efa5776c6959619377 100644 --- a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb +++ b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb @@ -5,7 +5,7 @@ describe GitlabSchema.types['AwardEmoji'] do it { expect(described_class.graphql_name).to eq('AwardEmoji') } - it { is_expected.to require_graphql_authorizations(:read_emoji) } + it { expect(described_class).to require_graphql_authorizations(:read_emoji) } it { expect(described_class).to have_graphql_fields(:description, :unicode_version, :emoji, :name, :unicode, :user) } end diff --git a/spec/graphql/types/board_type_spec.rb b/spec/graphql/types/board_type_spec.rb index 9d18065bbcde5fc259042115f245931fce319861..1ca4bf18b57fd56804ef2b13414995e36619c5b7 100644 --- a/spec/graphql/types/board_type_spec.rb +++ b/spec/graphql/types/board_type_spec.rb @@ -10,6 +10,6 @@ it 'has specific fields' do expected_fields = %w[id name] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/diff_refs_type_spec.rb b/spec/graphql/types/diff_refs_type_spec.rb index 85225e5809c4ef25378c529c63ef13ae40c9d827..a6ead27455f015e4c745e8a40d6792a96e72ae2e 100644 --- a/spec/graphql/types/diff_refs_type_spec.rb +++ b/spec/graphql/types/diff_refs_type_spec.rb @@ -5,7 +5,7 @@ describe GitlabSchema.types['DiffRefs'] do it { expect(described_class.graphql_name).to eq('DiffRefs') } - it { is_expected.to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } + it { expect(described_class).to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } it { expect(described_class.fields['headSha'].type).to be_non_null } it { expect(described_class.fields['baseSha'].type).not_to be_non_null } diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb index cf30893b3cada3681182e398a8060b390dc4d9a4..9e8f13e4c2e6edc5e236b818e814c5f473004406 100644 --- a/spec/graphql/types/environment_type_spec.rb +++ b/spec/graphql/types/environment_type_spec.rb @@ -10,8 +10,8 @@ name id ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_environment) } + it { expect(described_class).to require_graphql_authorizations(:read_environment) } end diff --git a/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb b/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb index 3a512fee3b377deaf2bdae2d600d96c1cb168758..44652f831b52f5a6147bfb010fa82ea793af5e61 100644 --- a/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb @@ -37,6 +37,6 @@ tags ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb index 3de0a359c15ff870dcaf4f668787f46dc06ea8f2..20ec31391d829724f7d5b404819e1da00d934cfe 100644 --- a/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb @@ -15,7 +15,7 @@ error_stack_trace ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'errors field' do diff --git a/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb index ce5fade6fcc92f900638bf68a3e6aa95addc7011..05cc2ca7612b35b8c29506e567360a51679ceb45 100644 --- a/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb @@ -14,6 +14,6 @@ trace_context ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb index ac41e6903e5744538515a28abb593f479f5c8627..2a422228f72cd756da58bf53a48328043b412012 100644 --- a/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb @@ -14,6 +14,6 @@ stack_trace_entries ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb index 51acd035024503dc609e40c0aa8dff3f2e3b21b9..4676d91ef9c01876c7059bd3324fc4cb7af4ae3d 100644 --- a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb @@ -26,6 +26,6 @@ frequency ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/grafana_integration_type_spec.rb b/spec/graphql/types/grafana_integration_type_spec.rb index ddfedc5a75c3032fce1f524d4e0149f294c187be..ac26911acbf9620f9f6e13200905ba04a0f5e0e6 100644 --- a/spec/graphql/types/grafana_integration_type_spec.rb +++ b/spec/graphql/types/grafana_integration_type_spec.rb @@ -18,5 +18,5 @@ it { expect(described_class).to require_graphql_authorizations(:admin_operations) } - it { is_expected.to have_graphql_fields(*expected_fields) } + it { expect(described_class).to have_graphql_fields(*expected_fields) } end diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index 240dd9fa5e251baee819424e9031720ee54268d9..532f1a4b53d8b643ae7b59b4f019db699309874e 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -19,7 +19,7 @@ mentions_disabled parent boards ] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end describe 'boards field' do diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index daa2224ef204f073f79cf87a0d26623cfe17079c..ebe48c17c111bd5348bd815346507c8f5ca457bf 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -9,7 +9,7 @@ it { expect(described_class).to require_graphql_authorizations(:read_issue) } - it { expect(described_class.interfaces).to include(Types::Notes::NoteableType.to_graphql) } + it { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } it 'has specific fields' do fields = %i[iid title description state reference author assignees participants labels milestone due_date diff --git a/spec/graphql/types/label_type_spec.rb b/spec/graphql/types/label_type_spec.rb index a023a75eeffe4f50695c505d604dece5054b65d0..71b86d9b528fc19286b73511aed7b6963f03141e 100644 --- a/spec/graphql/types/label_type_spec.rb +++ b/spec/graphql/types/label_type_spec.rb @@ -5,8 +5,8 @@ it 'has the correct fields' do expected_fields = [:id, :description, :description_html, :title, :color, :text_color] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_label) } + it { expect(described_class).to require_graphql_authorizations(:read_label) } end diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index 04e9bb6861f4586bbe16034fdfd3866e571ee13d..0c83ebd3de9b133fd39c352cc1545da20c262d51 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -7,7 +7,7 @@ it { expect(described_class).to require_graphql_authorizations(:read_merge_request) } - it { expect(described_class.interfaces).to include(Types::Notes::NoteableType.to_graphql) } + it { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } it 'has the expected fields' do expected_fields = %w[ @@ -25,6 +25,6 @@ total_time_spent reference ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/metadata_type_spec.rb b/spec/graphql/types/metadata_type_spec.rb index 2988f3c6ba59fe8f519478add1462a345ffea427..c8270a8c2f5ef1e5ebc1f582ed5e3dba6cc8b950 100644 --- a/spec/graphql/types/metadata_type_spec.rb +++ b/spec/graphql/types/metadata_type_spec.rb @@ -4,5 +4,5 @@ describe GitlabSchema.types['Metadata'] do it { expect(described_class.graphql_name).to eq('Metadata') } - it { is_expected.to require_graphql_authorizations(:read_instance_metadata) } + it { expect(described_class).to require_graphql_authorizations(:read_instance_metadata) } end diff --git a/spec/graphql/types/namespace_type_spec.rb b/spec/graphql/types/namespace_type_spec.rb index f476dd7286f1309526f15176084aa25922b8825a..6c2ba70cf4c6d1f7547ffb86c15c2e78fff1d31d 100644 --- a/spec/graphql/types/namespace_type_spec.rb +++ b/spec/graphql/types/namespace_type_spec.rb @@ -11,8 +11,8 @@ lfs_enabled request_access_enabled projects root_storage_statistics ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_namespace) } + it { expect(described_class).to require_graphql_authorizations(:read_namespace) } end diff --git a/spec/graphql/types/notes/diff_position_type_spec.rb b/spec/graphql/types/notes/diff_position_type_spec.rb index aa08daaacd4542eff1b210b32a81081237fe63a5..01f355cb2786e49c508e3be9beb1253f46611b25 100644 --- a/spec/graphql/types/notes/diff_position_type_spec.rb +++ b/spec/graphql/types/notes/diff_position_type_spec.rb @@ -7,6 +7,6 @@ :new_path, :position_type, :old_line, :new_line, :x, :y, :width, :height] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/notes/discussion_type_spec.rb b/spec/graphql/types/notes/discussion_type_spec.rb index ba7fc961212e8f97059095b36acb49891ce26260..804785ba67d5e35465e6201b1dfe51d9796f8c74 100644 --- a/spec/graphql/types/notes/discussion_type_spec.rb +++ b/spec/graphql/types/notes/discussion_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe GitlabSchema.types['Discussion'] do - it { is_expected.to have_graphql_fields(:id, :created_at, :notes, :reply_id) } + it { expect(described_class).to have_graphql_fields(:id, :created_at, :notes, :reply_id) } - it { is_expected.to require_graphql_authorizations(:read_note) } + it { expect(described_class).to require_graphql_authorizations(:read_note) } end diff --git a/spec/graphql/types/notes/note_type_spec.rb b/spec/graphql/types/notes/note_type_spec.rb index e8a58da4b1786e11dd5b4385ef161ca66e9d964d..809f54c120cd20e7a789e0338315bd893c34cdfb 100644 --- a/spec/graphql/types/notes/note_type_spec.rb +++ b/spec/graphql/types/notes/note_type_spec.rb @@ -7,9 +7,9 @@ :updated_at, :discussion, :resolvable, :position, :user_permissions, :resolved_by, :resolved_at, :system, :body_html] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to expose_permissions_using(Types::PermissionTypes::Note) } - it { is_expected.to require_graphql_authorizations(:read_note) } + it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Note) } + it { expect(described_class).to require_graphql_authorizations(:read_note) } end diff --git a/spec/graphql/types/notes/noteable_type_spec.rb b/spec/graphql/types/notes/noteable_type_spec.rb index d10c79b5344fe433eff26523820226d7416ecdb1..a4259e160e09b435ebc2a5423fa1b3eefaafd229 100644 --- a/spec/graphql/types/notes/noteable_type_spec.rb +++ b/spec/graphql/types/notes/noteable_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Types::Notes::NoteableType do - it { is_expected.to have_graphql_fields(:notes, :discussions) } + it { expect(described_class).to have_graphql_fields(:notes, :discussions) } describe ".resolve_type" do it 'knows the correct type for objects' do diff --git a/spec/graphql/types/permission_types/base_permission_type_spec.rb b/spec/graphql/types/permission_types/base_permission_type_spec.rb index aa6b432000631e85812cccbd849e6c5700a24a3a..4c6d5fd369ab4592f852f8b753053a35fd4f1e55 100644 --- a/spec/graphql/types/permission_types/base_permission_type_spec.rb +++ b/spec/graphql/types/permission_types/base_permission_type_spec.rb @@ -19,13 +19,13 @@ describe '.permission_field' do it 'adds a field for the required permission' do - is_expected.to have_graphql_field(:do_stuff) + expect(test_type).to have_graphql_field(:do_stuff) end end describe '.ability_field' do it 'adds a field for the required permission' do - is_expected.to have_graphql_field(:read_issue) + expect(test_type).to have_graphql_field(:read_issue) end it 'does not add a resolver block if another resolving param is passed' do @@ -44,7 +44,7 @@ describe '.abilities' do it 'adds a field for the passed permissions' do - is_expected.to have_graphql_field(:admin_issue) + expect(test_type).to have_graphql_field(:admin_issue) end end end diff --git a/spec/graphql/types/permission_types/note_spec.rb b/spec/graphql/types/permission_types/note_spec.rb index a7811fc20e50d4479c2959f34fec15520b54c412..a2becb6892b55fa358e64ef0a574579b0a3993cf 100644 --- a/spec/graphql/types/permission_types/note_spec.rb +++ b/spec/graphql/types/permission_types/note_spec.rb @@ -8,6 +8,6 @@ :read_note, :create_note, :admin_note, :resolve_note, :award_emoji ] - is_expected.to have_graphql_fields(expected_permissions) + expect(described_class).to have_graphql_fields(expected_permissions) end end diff --git a/spec/graphql/types/project_statistics_type_spec.rb b/spec/graphql/types/project_statistics_type_spec.rb index e9feac57a360da83757b03682bc19d18447e8758..fbea780494b05510bd2f8a0c748c370bc280d5e0 100644 --- a/spec/graphql/types/project_statistics_type_spec.rb +++ b/spec/graphql/types/project_statistics_type_spec.rb @@ -4,7 +4,7 @@ describe GitlabSchema.types['ProjectStatistics'] do it "has all the required fields" do - is_expected.to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, + expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :commit_count, :wiki_size) end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 9c6d1e3f35c40207c00bdd51531f70fd604ce1a2..475ae9ff5f62cec04d690928b17ab533ecfca2c0 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -27,7 +27,7 @@ boards ] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end describe 'issue field' do diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb index 236f9bb94593910eee39a4e898f1a7d9c2577340..f746e75b5742c912032cd35dd396698fd7e7375e 100644 --- a/spec/graphql/types/repository_type_spec.rb +++ b/spec/graphql/types/repository_type_spec.rb @@ -7,7 +7,7 @@ it { expect(described_class).to require_graphql_authorizations(:download_code) } - it { is_expected.to have_graphql_field(:root_ref) } + it { expect(described_class).to have_graphql_field(:root_ref) } - it { is_expected.to have_graphql_field(:tree) } + it { expect(described_class).to have_graphql_field(:tree) } end diff --git a/spec/graphql/types/root_storage_statistics_type_spec.rb b/spec/graphql/types/root_storage_statistics_type_spec.rb index 8c69c13aa737d12059f753df38e87350b4dffe29..b796b974b8292ec110d1b460fbadc2306e4d34fc 100644 --- a/spec/graphql/types/root_storage_statistics_type_spec.rb +++ b/spec/graphql/types/root_storage_statistics_type_spec.rb @@ -6,9 +6,9 @@ it { expect(described_class.graphql_name).to eq('RootStorageStatistics') } it 'has all the required fields' do - is_expected.to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, + expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :wiki_size) end - it { is_expected.to require_graphql_authorizations(:read_statistics) } + it { expect(described_class).to require_graphql_authorizations(:read_statistics) } end diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb index 97573f8c46be00be9e740a3e6fdf2918ee9c0da9..afac480d06b1ea6a15761d18264d4bb84c827e45 100644 --- a/spec/graphql/types/snippet_type_spec.rb +++ b/spec/graphql/types/snippet_type_spec.rb @@ -10,7 +10,7 @@ :web_url, :raw_url, :notes, :discussions, :user_permissions, :description_html, :blob] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'authorizations' do diff --git a/spec/graphql/types/snippets/blob_type_spec.rb b/spec/graphql/types/snippets/blob_type_spec.rb index b6253e96d60c51698f8b87a6286687ca92c2cf7e..da36ab80f44ae94da61ad81dc58f08502ed66f41 100644 --- a/spec/graphql/types/snippets/blob_type_spec.rb +++ b/spec/graphql/types/snippets/blob_type_spec.rb @@ -8,6 +8,6 @@ :raw_path, :size, :binary, :name, :path, :simple_viewer, :rich_viewer, :mode] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/snippets/blob_viewer_type_spec.rb b/spec/graphql/types/snippets/blob_viewer_type_spec.rb index f1f7608cb698d7744676cfc624715dd2f3674d78..a51d09813ab6cb8ca8bdf79f0ba90b0d4fa160bf 100644 --- a/spec/graphql/types/snippets/blob_viewer_type_spec.rb +++ b/spec/graphql/types/snippets/blob_viewer_type_spec.rb @@ -7,6 +7,6 @@ expected_fields = [:type, :load_async, :too_large, :collapsed, :render_error, :file_type, :loading_partial_name] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/todo_type_spec.rb b/spec/graphql/types/todo_type_spec.rb index a5ea5bcffb073ad885909bb4b01334a9885f850a..59118259d0941e6536fade9f5341ab322522a387 100644 --- a/spec/graphql/types/todo_type_spec.rb +++ b/spec/graphql/types/todo_type_spec.rb @@ -6,7 +6,7 @@ it 'has the correct fields' do expected_fields = [:id, :project, :group, :author, :action, :target_type, :body, :state, :created_at] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end it { expect(described_class).to require_graphql_authorizations(:read_todo) } diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index b9174b9a90be0e55c2a4f3904dbeaf968c9771ba..8c76ce43e9533845038841db87c7ea3a90389aaa 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -12,7 +12,7 @@ user_permissions snippets name username avatarUrl webUrl todos ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'snippets field' do diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index 370162b45f08fff9a5b515a367ec82f44f710cea..1bb942ff39b3931a53b229f1ae8106994f8470c5 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -71,10 +71,10 @@ def graphql_mutation(name, input, fields = nil) mutation_name = GraphqlHelpers.fieldnamerize(name) input_variable_name = "$#{input_variable_name_for_mutation(name)}" mutation_field = GitlabSchema.mutation.fields[mutation_name] - fields ||= all_graphql_fields_for(mutation_field.type) + fields ||= all_graphql_fields_for(mutation_field.type.to_graphql) query = <<~MUTATION - mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type}) { + mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type.to_graphql}) { #{mutation_name}(input: #{input_variable_name}) { #{fields} } @@ -118,15 +118,22 @@ def input_variable_name_for_mutation(mutation_name) GraphqlHelpers.fieldnamerize(input_type) end - def query_graphql_field(name, attributes = {}, fields = nil) - field_params = if attributes.present? + def field_with_params(name, attributes = {}) + namerized = GraphqlHelpers.fieldnamerize(name.to_s) + return "#{namerized}" if attributes.blank? + + field_params = if attributes.is_a?(Hash) "(#{attributes_to_graphql(attributes)})" else - '' + "(#{attributes})" end + "#{namerized}#{field_params}" + end + + def query_graphql_field(name, attributes = {}, fields = nil) <<~QUERY - #{GraphqlHelpers.fieldnamerize(name.to_s)}#{field_params} + #{field_with_params(name, attributes)} #{wrap_fields(fields || all_graphql_fields_for(name.to_s.classify))} QUERY end @@ -300,7 +307,7 @@ def io_value?(value) end def field_type(field) - field_type = field.type + field_type = field.type.respond_to?(:to_graphql) ? field.type.to_graphql : field.type # The type could be nested. For example `[GraphQL::STRING_TYPE]`: # - List diff --git a/spec/support/matchers/graphql_matchers.rb b/spec/support/matchers/graphql_matchers.rb index 31b0290bb15f1ae16cfad709c422c019b683dd9d..6439b68764e08a4bc0b0533ded5c473da727b4e0 100644 --- a/spec/support/matchers/graphql_matchers.rb +++ b/spec/support/matchers/graphql_matchers.rb @@ -2,7 +2,7 @@ RSpec::Matchers.define :require_graphql_authorizations do |*expected| match do |field| - expect(field.metadata[:authorize]).to eq(*expected) + expect(field.to_graphql.metadata[:authorize]).to eq(*expected) end end @@ -87,13 +87,13 @@ def expected_field_names RSpec::Matchers.define :have_graphql_type do |expected| match do |field| - expect(field.type).to eq(expected.to_graphql) + expect(field.type).to eq(expected) end end RSpec::Matchers.define :have_non_null_graphql_type do |expected| match do |field| - expect(field.type).to eq(!expected.to_graphql) + expect(field.type.to_graphql).to eq(!expected.to_graphql) end end @@ -101,16 +101,16 @@ def expected_field_names match do |field| case expected when Method - expect(field.metadata[:type_class].resolve_proc).to eq(expected) + expect(field.to_graphql.metadata[:type_class].resolve_proc).to eq(expected) else - expect(field.metadata[:type_class].resolver).to eq(expected) + expect(field.to_graphql.metadata[:type_class].resolver).to eq(expected) end end end RSpec::Matchers.define :have_graphql_extension do |expected| match do |field| - expect(field.metadata[:type_class].extensions).to include(expected) + expect(field.to_graphql.metadata[:type_class].extensions).to include(expected) end end diff --git a/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb b/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb index ca77c68c130e5e71ffa807edef9161241f1beeb3..4c80bbef153695c92d998cb6393d457dd02c154c 100644 --- a/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb +++ b/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb @@ -15,7 +15,7 @@ def query(board_params = params) board_parent_type, { 'fullPath' => board_parent.full_path }, <<~BOARDS - boards(#{board_params}) { + #{field_with_params('boards', board_params)} { pageInfo { startCursor endCursor @@ -35,7 +35,7 @@ def query_single_board(board_params = params) board_parent_type, { 'fullPath' => board_parent.full_path }, <<~BOARD - board(#{board_params}) { + #{field_with_params('board', board_params)} { #{all_graphql_fields_for('board'.classify)} } BOARD