diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/graphql/resolvers/design_management/versions_resolver.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/graphql/resolvers/design_management/versions_resolver.rb')
-rw-r--r-- | app/graphql/resolvers/design_management/versions_resolver.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/graphql/resolvers/design_management/versions_resolver.rb b/app/graphql/resolvers/design_management/versions_resolver.rb index a62258dad5c..23858c8e991 100644 --- a/app/graphql/resolvers/design_management/versions_resolver.rb +++ b/app/graphql/resolvers/design_management/versions_resolver.rb @@ -7,12 +7,14 @@ module Resolvers alias_method :design_or_collection, :object + VersionID = ::Types::GlobalIDType[::DesignManagement::Version] + argument :earlier_or_equal_to_sha, GraphQL::STRING_TYPE, as: :sha, required: false, description: 'The SHA256 of the most recent acceptable version' - argument :earlier_or_equal_to_id, GraphQL::ID_TYPE, + argument :earlier_or_equal_to_id, VersionID, as: :id, required: false, description: 'The Global ID of the most recent acceptable version' @@ -23,6 +25,9 @@ module Resolvers end def resolve(parent: nil, id: nil, sha: nil) + # TODO: remove this line when the compatibility layer is removed + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 + id &&= VersionID.coerce_isolated_input(id) version = cutoff(parent, id, sha) raise ::Gitlab::Graphql::Errors::ResourceNotAvailable, 'cutoff not found' unless version.present? @@ -47,8 +52,7 @@ module Resolvers end end - def specific_version(id, sha) - gid = GitlabSchema.parse_gid(id, expected_type: ::DesignManagement::Version) if id + def specific_version(gid, sha) find(sha: sha, version_id: gid&.model_id).first end @@ -58,8 +62,8 @@ module Resolvers .execute end - def by_id(id) - GitlabSchema.object_from_id(id, expected_type: ::DesignManagement::Version).sync + def by_id(gid) + ::Gitlab::Graphql::Lazy.force(GitlabSchema.find_by_gid(gid)) end # Find an `at_version` argument passed to a parent node. @@ -69,7 +73,11 @@ module Resolvers # for consistency we should only present versions up to the given # version here. def at_version_arg(parent) - ::Gitlab::Graphql::FindArgumentInParent.find(parent, :at_version, limit_depth: 4) + # TODO: remove coercion when the compatibility layer is removed + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 + version_id = ::Gitlab::Graphql::FindArgumentInParent.find(parent, :at_version, limit_depth: 4) + version_id &&= VersionID.coerce_isolated_input(version_id) + version_id end end end |