Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/resolvers/target.py
- This file was added.
from __future__ import annotations | |||||
from typing import TYPE_CHECKING, Union | |||||
from .base_node import BaseNode | |||||
# from swh.model.swhids import CoreSWHID, ObjectType | |||||
if TYPE_CHECKING: | |||||
# from .directory_entry import BaseDirectoryEntryNode | |||||
from .release import BaseReleaseNode | |||||
class TargetNode(BaseNode): | |||||
obj: Union[BaseReleaseNode] # , BaseDirectoryEntryNode] | |||||
def _get_node_data(self): | |||||
# node field of a target object is resolved in the top level resolver | |||||
return { | |||||
# field exposed in the schema | |||||
"type": self.obj.target_type, | |||||
# field exposed in the schema, the same field is used to | |||||
# get the node object | |||||
"identifier": self.obj.target_id, | |||||
# field NOT exposed in schema, used to get the target object | |||||
"target_id": self.obj.target_id, | |||||
} |