Commit 8d8ff533 authored by Alex Kalderimis's avatar Alex Kalderimis

Annotate resolvers that call gitaly

The following resolvers call gitaly:

- metrics/dashboard_resolver
- last_commit_resolver
- snippets/blobs_resolver
- tree_resolver

Remove an unnecessary gitaly annotation (I was unable to verify that
this gitaly annotation was needed. So it is removed.)
parent e300fad5
......@@ -12,8 +12,17 @@ module Resolvers
@requires_argument = true
end
def self.calls_gitaly!
@calls_gitaly = true
end
def self.field_options
super.merge(requires_argument: @requires_argument)
extra_options = {
requires_argument: @requires_argument,
calls_gitaly: @calls_gitaly
}.compact
super.merge(extra_options)
end
def self.singular_type
......
......@@ -4,6 +4,8 @@ module Resolvers
class LastCommitResolver < BaseResolver
type Types::CommitType, null: true
calls_gitaly!
alias_method :tree, :object
def resolve(**args)
......
......@@ -3,19 +3,30 @@
module Resolvers
module Metrics
class DashboardResolver < Resolvers::BaseResolver
type Types::Metrics::DashboardType, null: true
calls_gitaly!
argument :path, GraphQL::STRING_TYPE,
required: true,
description: "Path to a file which defines metrics dashboard eg: 'config/prometheus/common_metrics.yml'."
type Types::Metrics::DashboardType, null: true
description: "Path to a file which defines metrics dashboard " \
"eg: 'config/prometheus/common_metrics.yml'."
alias_method :environment, :object
def resolve(**args)
return unless environment
::PerformanceMonitoring::PrometheusDashboard
.find_for(project: environment.project, user: context[:current_user], path: args[:path], options: { environment: environment })
::PerformanceMonitoring::PrometheusDashboard.find_for(**args, **service_params)
end
private
def service_params
{
project: environment.project,
user: current_user,
options: { environment: environment }
}
end
end
end
......
......@@ -8,6 +8,7 @@ module Resolvers
type Types::Snippets::BlobType.connection_type, null: true
authorize :read_snippet
calls_gitaly!
alias_method :snippet, :object
......
......@@ -4,6 +4,8 @@ module Resolvers
class TreeResolver < BaseResolver
type Types::Tree::TreeType, null: true
calls_gitaly!
argument :path, GraphQL::STRING_TYPE,
required: false,
default_value: '',
......
......@@ -14,7 +14,6 @@ module Types
field :plain_data, GraphQL::STRING_TYPE,
description: 'Blob plain highlighted data.',
calls_gitaly: true,
null: true
field :raw_path, GraphQL::STRING_TYPE,
......
......@@ -15,6 +15,7 @@ module Types
field :web_path, GraphQL::STRING_TYPE, null: true,
description: 'Web path of the blob.'
field :lfs_oid, GraphQL::STRING_TYPE, null: true,
calls_gitaly: true,
description: 'LFS ID of the blob.'
field :mode, GraphQL::STRING_TYPE, null: true,
description: 'Blob mode in numeric format.'
......
......@@ -79,7 +79,7 @@ module Gitlab
end
def field_name
"#{field.owner_type.graphql_name}.#{field.graphql_name}"
"#{field.owner.graphql_name}.#{field.graphql_name}"
end
end
end
......
......@@ -38,7 +38,10 @@ module GraphqlHelpers
# All resolution goes through fields, so we need to create one here that
# uses our resolver. Thankfully, apart from the field name, resolvers
# contain all the configuration needed to define one.
field_options = resolver_class.field_options.merge(name: 'field_value')
field_options = resolver_class.field_options.merge(
owner: resolver_parent,
name: 'field_value'
)
field = ::Types::BaseField.new(**field_options)
# All mutations accept a single `:input` argument. Wrap arguments here.
......
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