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.utils import utils | from swh.graphql.utils import utils | ||||
from swh.storage.interface import PagedResult | from swh.storage.interface import PagedResult | ||||
from .base_connection import BaseConnection | from .base_connection import BaseConnection | ||||
from .base_node import BaseNode | from .base_node import BaseNode | ||||
class BaseDirectoryEntryNode(BaseNode): | class BaseDirectoryEntryNode(BaseNode): | ||||
@property | @property | ||||
def target_hash(self): # for DirectoryNode | def target_id(self): | ||||
return self._node.target | return self._node.target | ||||
@property | @property | ||||
def targetType(self): # To support the schema naming convention | def target_type(self): | ||||
mapping = {"file": "content", "dir": "directory", "rev": "revision"} | mapping = {"file": "content", "dir": "directory", "rev": "revision"} | ||||
return mapping.get(self._node.type) | return mapping.get(self._node.type) | ||||
class DirectoryEntryNode(BaseDirectoryEntryNode): | class DirectoryEntryNode(BaseDirectoryEntryNode): | ||||
""" | """ | ||||
Node resolver for a directory entry requested with a | Node resolver for a directory entry requested with a | ||||
directory SWHID and a relative path | directory SWHID and a relative path | ||||
Show All 36 Lines |