summaryrefslogtreecommitdiff
path: root/app/graphql/gitlab_schema.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/gitlab_schema.rb')
-rw-r--r--app/graphql/gitlab_schema.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/graphql/gitlab_schema.rb b/app/graphql/gitlab_schema.rb
index 7ab5dc36e4a..8369d0e120f 100644
--- a/app/graphql/gitlab_schema.rb
+++ b/app/graphql/gitlab_schema.rb
@@ -12,7 +12,6 @@ class GitlabSchema < GraphQL::Schema
use GraphQL::Pagination::Connections
use BatchLoader::GraphQL
- use Gitlab::Graphql::Authorize
use Gitlab::Graphql::Pagination::Connections
use Gitlab::Graphql::GenericTracing
use Gitlab::Graphql::Timeout, max_seconds: Gitlab.config.gitlab.graphql_timeout
@@ -32,9 +31,10 @@ class GitlabSchema < GraphQL::Schema
class << self
def multiplex(queries, **kwargs)
- kwargs[:max_complexity] ||= max_query_complexity(kwargs[:context])
+ kwargs[:max_complexity] ||= max_query_complexity(kwargs[:context]) unless kwargs.key?(:max_complexity)
queries.each do |query|
+ query[:max_complexity] ||= max_query_complexity(kwargs[:context]) unless query.key?(:max_complexity)
query[:max_depth] = max_query_depth(kwargs[:context])
end
@@ -111,6 +111,7 @@ class GitlabSchema < GraphQL::Schema
#
# Options:
# * :expected_type [Class] - the type of object this GlobalID should refer to.
+ # * :expected_type [[Class]] - array of the types of object this GlobalID should refer to.
#
# e.g.
#
@@ -120,14 +121,14 @@ class GitlabSchema < GraphQL::Schema
# gid.model_class == ::Project
# ```
def parse_gid(global_id, ctx = {})
- expected_type = ctx[:expected_type]
+ expected_types = Array(ctx[:expected_type])
gid = GlobalID.parse(global_id)
raise Gitlab::Graphql::Errors::ArgumentError, "#{global_id} is not a valid GitLab ID." unless gid
- if expected_type && !gid.model_class.ancestors.include?(expected_type)
- vars = { global_id: global_id, expected_type: expected_type }
- msg = _('%{global_id} is not a valid ID for %{expected_type}.') % vars
+ if expected_types.any? && expected_types.none? { |type| gid.model_class.ancestors.include?(type) }
+ vars = { global_id: global_id, expected_types: expected_types.join(', ') }
+ msg = _('%{global_id} is not a valid ID for %{expected_types}.') % vars
raise Gitlab::Graphql::Errors::ArgumentError, msg
end