Commit d10ac87d authored by Luke Duncalfe's avatar Luke Duncalfe Committed by charlie ablett

Add missing calls_gitaly to fields

Our CallsGitaly::Instrumentation notifies us if a field is calling
Gitaly without being marked as such:
https://gitlab.com/gitlab-org/gitlab/-/blob/035e73598f8910b95b902b30dd3bcae7b3cd5d8d/lib/gitlab/graphql/calls_gitaly/instrumentation.rb#L34-35

We can see notifications in Sentry for these fields, so adding the
missing `calls_gitaly: true` properties to the fields.
parent f7447302
......@@ -10,7 +10,7 @@ module Types
description: 'Default branch of the repository'
field :empty, GraphQL::BOOLEAN_TYPE, null: false, method: :empty?, calls_gitaly: true,
description: 'Indicates repository has no visible content'
field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists?,
field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists?, calls_gitaly: true,
description: 'Indicates a corresponding Git repository exists on disk'
field :tree, Types::Tree::TreeType, null: true, resolver: Resolvers::TreeResolver, calls_gitaly: true,
description: 'Tree of the repository'
......
---
title: Increase the complexity score of GraphQL MergeRequest#approved, MergeRequest#approvalsLeft
and Repository#exists fields as they can call Gitaly
merge_request: 47039
author:
type: changed
......@@ -6,9 +6,9 @@ module EE
extend ActiveSupport::Concern
prepended do
field :approved, GraphQL::BOOLEAN_TYPE, method: :approved?, null: false,
field :approved, GraphQL::BOOLEAN_TYPE, method: :approved?, null: false, calls_gitaly: true,
description: 'Indicates if the merge request has all the required approvals. Returns true if no required approvals are configured.'
field :approvals_left, GraphQL::INT_TYPE, null: true,
field :approvals_left, GraphQL::INT_TYPE, null: true, calls_gitaly: true,
description: 'Number of approvals left'
field :approvals_required, GraphQL::INT_TYPE, null: true,
description: 'Number of approvals required'
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['MergeRequest'] do
it { expect(described_class).to have_graphql_fields(:approvals_required, :merge_trains_count).at_least }
it { expect(described_class).to have_graphql_field(:approved, complexity: 2, calls_gitaly?: true) }
it { expect(described_class).to have_graphql_field(:approvals_left, complexity: 2, calls_gitaly?: true) }
end
......@@ -32,14 +32,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
has_ci mergeable commits_without_merge_commits squash security_auto_fix default_squash_commit_message
]
if Gitlab.ee?
expected_fields << 'approved'
expected_fields << 'approvals_left'
expected_fields << 'approvals_required'
expected_fields << 'merge_trains_count'
end
expect(described_class).to have_graphql_fields(*expected_fields)
expect(described_class).to have_graphql_fields(*expected_fields).at_least
end
describe '#pipelines' do
......
......@@ -10,4 +10,6 @@ RSpec.describe GitlabSchema.types['Repository'] do
specify { expect(described_class).to have_graphql_field(:root_ref) }
specify { expect(described_class).to have_graphql_field(:tree) }
specify { expect(described_class).to have_graphql_field(:exists, calls_gitaly?: true, complexity: 2) }
end
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