Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/resolvers/revision.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 typing import Union | from typing import Union | ||||
from swh.graphql.utils import utils | from swh.graphql.utils import utils | ||||
from swh.model.model import Revision | from swh.model.model import Revision | ||||
from swh.model.swhids import CoreSWHID, ObjectType | from swh.model.swhids import CoreSWHID, ObjectType | ||||
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 BaseSWHNode | from .base_node import BaseSWHNode | ||||
from .directory_entry import BaseDirectoryEntryNode | from .directory_entry import BaseDirectoryEntryNode | ||||
from .release import BaseReleaseNode | from .release import BaseReleaseNode | ||||
from .search import SearchResultNode | |||||
from .snapshot_branch import BaseSnapshotBranchNode | from .snapshot_branch import BaseSnapshotBranchNode | ||||
class BaseRevisionNode(BaseSWHNode): | class BaseRevisionNode(BaseSWHNode): | ||||
""" | """ | ||||
Base resolver for all the revision nodes | Base resolver for all the revision nodes | ||||
""" | """ | ||||
Show All 30 Lines | def _get_node_data(self): | ||||
return self._get_revision_by_id(self.kwargs.get("swhid").object_id) | return self._get_revision_by_id(self.kwargs.get("swhid").object_id) | ||||
class TargetRevisionNode(BaseRevisionNode): | class TargetRevisionNode(BaseRevisionNode): | ||||
""" | """ | ||||
Node resolver for a revision requested as a target | Node resolver for a revision requested as a target | ||||
""" | """ | ||||
obj: Union[BaseSnapshotBranchNode, BaseReleaseNode, BaseDirectoryEntryNode] | obj: Union[ | ||||
BaseSnapshotBranchNode, | |||||
BaseReleaseNode, | |||||
BaseDirectoryEntryNode, | |||||
SearchResultNode, | |||||
] | |||||
def _get_node_data(self): | def _get_node_data(self): | ||||
# self.obj.target_hash is the requested revision id | # self.obj.target_hash is the requested revision id | ||||
return self._get_revision_by_id(self.obj.target_hash) | return self._get_revision_by_id(self.obj.target_hash) | ||||
class ParentRevisionConnection(BaseConnection): | class ParentRevisionConnection(BaseConnection): | ||||
""" | """ | ||||
Show All 39 Lines |