diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 00:09:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 00:09:27 +0300 |
commit | c9bef85d79791d41292d2f0727eb362034ebba1e (patch) | |
tree | cb35ec5eb6a83c5d311c8b61ea213450972d8026 /app/graphql/gitlab_schema.rb | |
parent | 6463521e08b00e62d3c877aefd8517f5387d54ab (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/gitlab_schema.rb')
-rw-r--r-- | app/graphql/gitlab_schema.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/graphql/gitlab_schema.rb b/app/graphql/gitlab_schema.rb index 76ac29fedeb..8369d0e120f 100644 --- a/app/graphql/gitlab_schema.rb +++ b/app/graphql/gitlab_schema.rb @@ -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.exclude?(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 |