Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/resolvers/directory_entry.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from swh.graphql.backends import archive | from swh.graphql.backends import archive | ||||
from swh.graphql.utils import utils | from swh.graphql.utils import utils | ||||
from .base_connection import BaseConnection | from .base_connection import BaseConnection | ||||
from .base_node import BaseNode | from .base_node import BaseNode | ||||
from .directory import BaseDirectoryNode | |||||
class DirectoryEntryNode(BaseNode): | class DirectoryEntryNode(BaseNode): | ||||
""" """ | """ | ||||
Node resolver for a directory entry | |||||
""" | |||||
@property | @property | ||||
def targetHash(self): # To support the schema naming convention | def targetHash(self): # To support the schema naming convention | ||||
return self._node.target | return self._node.target | ||||
class DirectoryEntryConnection(BaseConnection): | class DirectoryEntryConnection(BaseConnection): | ||||
_node_class = DirectoryEntryNode | |||||
def _get_paged_result(self): | |||||
""" | """ | ||||
When entries requested from a directory | Connection resolver for entries in a directory | ||||
self.obj.swhid is the directory SWHID here | |||||
This is not paginated from swh-storgae | |||||
using dummy pagination | |||||
""" | """ | ||||
obj: BaseDirectoryNode | |||||
_node_class = DirectoryEntryNode | |||||
vlorentz: would an annotation work here too? | |||||
Not Done Inline Actionsyou can remove the comment now vlorentz: you can remove the comment now | |||||
def _get_paged_result(self): | |||||
# FIXME, using dummy(local) pagination, move pagination to backend | # FIXME, using dummy(local) pagination, move pagination to backend | ||||
# To remove localpagination, just drop the paginated call | # To remove localpagination, just drop the paginated call | ||||
# STORAGE-TODO | # STORAGE-TODO | ||||
entries = ( | entries = ( | ||||
archive.Archive().get_directory_entries(self.obj.swhid.object_id).results | archive.Archive().get_directory_entries(self.obj.swhid.object_id).results | ||||
) | ) | ||||
return utils.paginated(entries, self._get_first_arg(), self._get_after_arg()) | return utils.paginated(entries, self._get_first_arg(), self._get_after_arg()) |
would an annotation work here too?