diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/graphql/gitlab_schema.rb | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/graphql/gitlab_schema.rb')
-rw-r--r-- | app/graphql/gitlab_schema.rb | 13 |
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 |