diff --git a/swh/graphql/resolvers/branch.py b/swh/graphql/resolvers/branch.py index 32a5867..c1f1299 100644 --- a/swh/graphql/resolvers/branch.py +++ b/swh/graphql/resolvers/branch.py @@ -1,20 +1,21 @@ # from swh.graphql.backends import archive from swh.storage.interface import PagedResult from .base_connection import BaseConnection class SnapshotBranchConnection(BaseConnection): def _get_page_result(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 this in swh-storage + # FIX id results = [ - {"name": key, "type": value["target_type"]} + {"name": key, "type": value["target_type"], "id": "temp-id"} for (key, value) in self.obj["branches"].items() ] # FIXME, this pagination is broken, fix it with swh-storage return PagedResult(results=results, next_page_token=self.obj["next_branch"]) diff --git a/swh/graphql/resolvers/content.py b/swh/graphql/resolvers/content.py new file mode 100644 index 0000000..2e20f6c --- /dev/null +++ b/swh/graphql/resolvers/content.py @@ -0,0 +1,6 @@ +from .base_node import BaseNode + + +class ContentNode(BaseNode): + def _get_node(self): + pass diff --git a/swh/graphql/resolvers/directory.py b/swh/graphql/resolvers/directory.py new file mode 100644 index 0000000..c36b764 --- /dev/null +++ b/swh/graphql/resolvers/directory.py @@ -0,0 +1,7 @@ +from .base_node import BaseNode + + +class DirectoryNode(BaseNode): + def _get_node(self): + """ + """ diff --git a/swh/graphql/schema/schema.graphql b/swh/graphql/schema/schema.graphql index fab0110..3fc71cd 100644 --- a/swh/graphql/schema/schema.graphql +++ b/swh/graphql/schema/schema.graphql @@ -1,164 +1,216 @@ 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! + 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] } 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 } 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 + type Branch implements Node { # FIXME, maybe implement Node is not needed here - # This has no independent existence + # As this has no independent existence id: ID! name: BinaryText type: String # FIXME, change to an enum - # target: +} + +type Revision implements SWHNode { + id: SWHId! +} + +type Release implements SWHNode { + id: SWHId! +} + +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() -# Make revisionconnection -# Make contnetConnection + # """ + # 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 +}