Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/swh/graphql/resolvers/visit.py b/swh/graphql/resolvers/visit.py
index 5ce59d3..877f1fd 100644
--- a/swh/graphql/resolvers/visit.py
+++ b/swh/graphql/resolvers/visit.py
@@ -1,47 +1,51 @@
from swh.graphql.backends import archive
from swh.graphql.utils import utils
from .base_connection import BaseConnection
from .base_node import BaseNode
class BaseVisitNode(BaseNode):
@property
def id(self):
# FIXME, use a better id
return utils.b64encode(f"{self.origin}-{str(self.visit)}")
+ @property
+ def visitId(self): # To support the schema naming convention
+ return self._node.visit
+
class OriginVisitNode(BaseVisitNode):
"""
Get the visit directly with an origin URL and a visit ID
"""
def _get_node_data(self):
return archive.Archive().get_origin_visit(
self.kwargs.get("originUrl"), int(self.kwargs.get("visitId"))
)
class LatestVisitNode(BaseVisitNode):
"""
Get the latest visit for an origin
self.obj is the origin object here
self.obj.url is the origin URL
"""
def _get_node_data(self):
return archive.Archive().get_origin_latest_visit(self.obj.url)
class OriginVisitConnection(BaseConnection):
_node_class = BaseVisitNode
def _get_paged_result(self):
"""
Get the visits for the given origin
parent obj (self.obj) is origin here
"""
return archive.Archive().get_origin_visits(
self.obj.url, after=self._get_after_arg(), first=self._get_first_arg()
)
diff --git a/swh/graphql/resolvers/visit_status.py b/swh/graphql/resolvers/visit_status.py
index f0b69a8..c1c148b 100644
--- a/swh/graphql/resolvers/visit_status.py
+++ b/swh/graphql/resolvers/visit_status.py
@@ -1,37 +1,37 @@
from swh.graphql.backends import archive
from .base_connection import BaseConnection
from .base_node import BaseNode
class BaseVisitStatusNode(BaseNode):
""" """
class LatestVisitStatusNode(BaseVisitStatusNode):
"""
Get the latest visit status for a visit
self.obj is the visit object here
self.obj.origin is the origin URL
"""
def _get_node_data(self):
return archive.Archive().get_latest_visit_status(
- self.obj.origin, self.obj.visit
+ self.obj.origin, self.obj.visitId
)
class VisitStatusConnection(BaseConnection):
"""
self.obj is the visit object
"""
_node_class = BaseVisitStatusNode
def _get_paged_result(self):
return archive.Archive().get_visit_status(
self.obj.origin,
- self.obj.visit,
+ self.obj.visitId,
after=self._get_after_arg(),
first=self._get_first_arg(),
)
diff --git a/swh/graphql/schema/schema.graphql b/swh/graphql/schema/schema.graphql
index 80cbae2..1736da5 100644
--- a/swh/graphql/schema/schema.graphql
+++ b/swh/graphql/schema/schema.graphql
@@ -1,346 +1,346 @@
scalar SWHID
scalar Sha1
scalar DateTime
scalar DateTimeZone
scalar BinaryText
interface Node {
id: ID!
}
# interface SWHIDNode {
# id: SWHID!
# }
interface SWHNode {
id: Sha1!
}
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: Sha1!
url: String!
visits(
first: Int
after: String
): VisitConnection!
latestVisit: Visit
}
type VisitConnection {
edges: [VisitEdge]
nodes: [Visit]
pageInfo: PageInfo!
totalCount: Int
}
type VisitEdge {
cursor: String!
node: Visit
}
type Visit implements Node {
id: ID!
- visit: Int
+ visitId: Int
date: DateTime!
type: String
status(
first: Int
after: String
): VisitStatusConnection
latestStatus: VisitStatus
# 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 {
status: String!
date: DateTime!
snapshot: Snapshot
type: String
}
# FIXME, add OriginSnapshotConnection
type Snapshot implements SWHNode {
id: Sha1!
branches(
first: Int
after: String
types: [BranchTypes]
): BranchConnection
# 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
}
type Person {
email: BinaryText
name: BinaryText
fullname: BinaryText
}
# FIXME, this can be Content, Directory, Snapshot, or Alias as well
union BranchTarget = Revision | Release
enum BranchTypes {
revision
release
}
type Branch {
name: BinaryText
type: BranchTypes
targetId: Sha1
target: BranchTarget
}
type RevisionConnection {
edges: [RevisionEdge]
nodes: [Revision]
pageInfo: PageInfo!
totalCount: Int
}
type RevisionEdge {
cursor: String!
node: Revision
}
type Revision implements SWHNode {
id: Sha1!
message: BinaryText
author: Person
committer: Person
date: DateTimeZone
type: String # Revision type: FIXME, change to an enum
directoryId: Sha1
directory: Directory
parentIds: [Sha1]
parents(
first: Int
after: String
): RevisionConnection
# log
}
# type ReleaseConnection {
# }
# type ReleasEdge {
# }
union ReleaseTarget = Release | Revision | Directory | Content
enum ReleaseTargetType {
release
revision
content
directory
}
type Release implements SWHNode {
id: Sha1!
name: BinaryText
message: BinaryText
author: Person
date: DateTimeZone
targetId: Sha1
targetType: ReleaseTargetType
target: ReleaseTarget
}
type DirectoryEntryConnection {
edges: [DirectoryEntryEdge]
nodes: [DirectoryEntry]
pageInfo: PageInfo!
totalCount: Int
}
type DirectoryEntryEdge {
cursor: String!
node: DirectoryEntry
}
union DirectoryEntryTarget = Directory | Content
enum DirectoryEntryType {
dir
file
rev
}
type DirectoryEntry {
name: BinaryText
type: DirectoryEntryType
targetId: Sha1
target: DirectoryEntryTarget
}
type Directory implements SWHNode {
id: Sha1!
entries(
first: Int
after: String
): DirectoryEntryConnection
}
type ContentChecksum { # FIXME, temp types
blake2s256: Sha1
sha1: Sha1
sha1_git: Sha1
sha256: Sha1
}
# type ContentType {
# test: String
# }
# type ContentLanguage {
# test: String
# }
# type ContentLicense {
# test: String
# }
type Content implements SWHNode {
id: Sha1!
swhid: String
checksum: ContentChecksum
# data:
# filetype: ContentType
# language: ContentLanguage
# license: ContentLicense
length: Int
status: String
data: BinaryText
}
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!
visitId: Int!
): Visit
"""
Get a snapshot with SWHID
"""
snapshot(
Sha1: 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(
Sha1: String!
): Revision
"""
Get the release with the given swhid
"""
release(
Sha1: String!
): Release
"""
Get the directory with the given swhid
"""
directory(
Sha1: String!
): Directory
"""
Get the content with the given swhid
"""
content(
SWHID: String!
): Content
# """
# Search with the given swhid
# """
# searchWithSwhid
}

File Metadata

Mime Type
text/x-diff
Expires
Jul 4 2025, 6:38 PM (5 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3302226

Event Timeline