diff --git a/swh/graphql/backends/archive.py b/swh/graphql/backends/archive.py --- a/swh/graphql/backends/archive.py +++ b/swh/graphql/backends/archive.py @@ -81,4 +81,4 @@ ObjectType.REVISION: self.storage.revision_missing, ObjectType.SNAPSHOT: self.storage.snapshot_missing, } - return not mapping[object_type]([object_id]) + return not list(mapping[object_type]([object_id])) diff --git a/swh/graphql/tests/functional/test_swhid_resolve.py b/swh/graphql/tests/functional/test_swhid_resolve.py --- a/swh/graphql/tests/functional/test_swhid_resolve.py +++ b/swh/graphql/tests/functional/test_swhid_resolve.py @@ -6,7 +6,13 @@ import pytest from . import utils -from ..data import get_directories, get_releases, get_revisions, get_snapshots +from ..data import ( + get_contents, + get_directories, + get_releases, + get_revisions, + get_snapshots, +) def test_invalid_swhid(client): @@ -180,3 +186,36 @@ ] } } + + +@pytest.mark.parametrize("content", get_contents()) +def test_content_swhid_resolve(client, content, storage): + query_str = """ + { + resolveSwhid(swhid: "%s") { + nodes { + type + target { + __typename + ... on Content { + swhid + } + } + } + } + } + """ + data, _ = utils.get_query_response(client, query_str % content.swhid()) + assert data == { + "resolveSwhid": { + "nodes": [ + { + "target": { + "__typename": "Content", + "swhid": str(content.swhid()), + }, + "type": "content", + } + ] + } + }