diff --git a/swh/graphql/resolvers/snapshot_branch.py b/swh/graphql/resolvers/snapshot_branch.py index 0058b33..a39af4e 100644 --- a/swh/graphql/resolvers/snapshot_branch.py +++ b/swh/graphql/resolvers/snapshot_branch.py @@ -1,24 +1,40 @@ # from swh.graphql.backends import archive from swh.graphql.models import SnapshotBranchModel + +# from swh.graphql.utils import utils from swh.storage.interface import PagedResult from .base_connection import BaseConnection class SnapshotBranchConnection(BaseConnection): _model_class = SnapshotBranchModel def _get_page_result(self): + # FIXME making extra query to the storage + # This is failing now (STORAGEFIX) + # This is not really needed as we have the data + # in the self.obj itself + # Mocking paged data + # result = archive.Archive().get_snapshot_branches( + # utils.str_to_swid(self.obj.id.hex()), + # after=self._get_after_arg(), + # first=self._get_first_arg()) + # return PagedResult(results=result['branches'], + # next_page_token=result['next_branch']) + return self._get_from_parent_node() + + def _get_from_parent_node(self): """ Branches are avaialble in the snapshot object itself Not making a query """ - # FIXME Mocking PagedResult to make base_connection work - # FIX this in swh-storage - # FIX id results = [ {"name": key, "type": value["target_type"], "id": "temp-id"} for (key, value) in self.obj.branches.items() - ][:5] + ] # FIXME, this pagination is broken, fix it with swh-storage return PagedResult(results=results, next_page_token=self.obj.next_branch) + + def total_count(self): + return None diff --git a/swh/graphql/schema/schema.graphql b/swh/graphql/schema/schema.graphql index 3fc71cd..4d4d210 100644 --- a/swh/graphql/schema/schema.graphql +++ b/swh/graphql/schema/schema.graphql @@ -1,216 +1,223 @@ scalar SWHId scalar DateTime scalar BinaryText interface Node { id: ID! } interface SWHNode { id: SWHId! } type PageInfo { endCursor: String hasNextPage: Boolean! } + type OriginConnection { edges: [OriginEdge] nodes: [Origin] pageInfo: PageInfo! totalCount: Int } type OriginEdge { cursor: String! node: Origin } type Origin implements SWHNode { id: SWHId! # FIXME, this is not swhid url: String! visits( first: Int after: String ): VisitConnection! } type VisitConnection { edges: [VisitEdge] nodes: [Visit] pageInfo: PageInfo! totalCount: Int } type VisitEdge { cursor: String! node: Visit } type Visit implements Node { id: ID! date: DateTime! type: String status( first: Int after: String ): VisitStatusConnection # origin: Origin # FIXME, this can be added later } type VisitStatusConnection { edges: [VisitStatusEdge] nodes: [VisitStatus] pageInfo: PageInfo! totalCount: Int } type VisitStatusEdge { cursor: String! - node: [VisitStatus] + node: VisitStatus } type VisitStatus implements Node { id: ID! status: String! date: DateTime! snapshot: Snapshot type: String } # FIXME, add OriginSnapshotConnection type Snapshot implements SWHNode { id: SWHId! - """ - This pagination is broken at the moment - """ branches( first: Int after: String ): BranchConnection - # revisions( - # first: Int - # after: String - # ): RevisionConnection - # releases( # first: Int # after: String # ): ReleaseConnection + # FIXME, add alias type as well } type BranchConnection { edges: [BranchConnectionEdge] nodes: [Branch] pageInfo: PageInfo! totalCount: Int } type BranchConnectionEdge { cursor: String! node: [Branch] } -# QN: Not sure about this, maybe it is better to have -# different lists for revisions, releases etc -# instead of branches list in Snapshot -# union BranchTarget = Revision | Release +# FIXME, this could be an alias type as well +union BranchTarget = Revision | Release type Branch implements Node { # FIXME, maybe implement Node is not needed here # As this has no independent existence id: ID! name: BinaryText type: String # FIXME, change to an enum + target: BranchTarget } +# type RevisionConnection { +# } + +# type RevisionEdge { +# } + type Revision implements SWHNode { id: SWHId! + name: String } +# type ReleaseConnection { +# } + +# type ReleasEdge { +# } + type Release implements SWHNode { id: SWHId! + age: String } type Directory implements SWHNode { id: SWHId! } type Content implements SWHNode { id: SWHId! } type Query { """ Get an origin with its url """ # FIXME, find some unique id to help cache # maybe base64 encode the URL origin( url: String! ): Origin """ Get a list of origins matching the given filters Can also be used to search for an origin """ # FIMXE, use Input types to make this cleaner origins( first: Int after: String ): OriginConnection """ Get a visit object with its id and/or origin and visit id """ # FIXME, find some unique id to help cache visit( originUrl: String! id: String! ): Visit """ Get a snapshot with SWHId """ snapshot( SWHId: String! ): Snapshot # """ # Get all the snapshot for the given origin # """ # originSnapshot( # originUrl: String! # first: Int # after: String # ): SnapshotConnection # """ # Get the revision with the given swhid # """ # revision() # """ # Get the directory with the given swhid # """ # directory # """ # Get the content with the given swhid # """ # content( # SWHId: String! # ): Content # """ # Search with the given swhid # """ # searchWithSwhid }