Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9345692
D8911.id32224.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Subscribers
None
D8911.id32224.diff
View Options
diff --git a/swh/graphql/resolvers/visit.py b/swh/graphql/resolvers/visit.py
--- a/swh/graphql/resolvers/visit.py
+++ b/swh/graphql/resolvers/visit.py
@@ -70,3 +70,7 @@
return self.archive.get_origin_visits(
self.obj.url, after=self._get_after_arg(), first=self._get_first_arg()
)
+
+ # def _get_index_cursor(self, index: int, node: BaseVisitNode):
+ # # Origin visit is using visit number as the cursor
+ # return utils.get_encoded_cursor(str(node.visitId))
diff --git a/swh/graphql/schema/schema.graphql b/swh/graphql/schema/schema.graphql
--- a/swh/graphql/schema/schema.graphql
+++ b/swh/graphql/schema/schema.graphql
@@ -93,10 +93,10 @@
Edge in origin connection
"""
type OriginEdge {
- """
- Cursor to request the next page after the item
- """
- cursor: String!
+ # """
+ # Cursor to request the next page after the item
+ # """
+ # cursor: String!
"""
Origin object
@@ -198,10 +198,10 @@
Edge in origin visit connection
"""
type VisitEdge {
- """
- Cursor to request the next page after the item
- """
- cursor: String!
+ # """
+ # Cursor to request the next page after the item
+ # """
+ # cursor: String!
"""
Visit object
@@ -305,10 +305,10 @@
Edge in visit status connection
"""
type VisitStatusEdge {
- """
- Cursor to request the next page after the item
- """
- cursor: String!
+ # """
+ # Cursor to request the next page after the item
+ # """
+ # cursor: String!
"""
Visit status object
@@ -455,10 +455,10 @@
Edge in snapshot branch connection
"""
type BranchConnectionEdge {
- """
- Cursor to request the next page after the item
- """
- cursor: String!
+ # """
+ # Cursor to request the next page after the item
+ # """
+ # cursor: String!
"""
Branch object
@@ -933,10 +933,10 @@
Edge in SearchResult connection
"""
type SearchResultEdge {
- """
- Cursor to request the next page after the item
- """
- cursor: String!
+ # """
+ # Cursor to request the next page after the item
+ # """
+ # cursor: String!
"""
SearchResult object
diff --git a/swh/graphql/tests/functional/test_branch_connection.py b/swh/graphql/tests/functional/test_branch_connection.py
--- a/swh/graphql/tests/functional/test_branch_connection.py
+++ b/swh/graphql/tests/functional/test_branch_connection.py
@@ -18,9 +18,6 @@
pageInfo {
endCursor
}
- edges {
- cursor
- }
nodes {
targetType
name {
@@ -147,6 +144,6 @@
second_data, _ = get_branches(client, swhid=swhid, first=3, after=end_cursor)
branches = second_data["snapshot"]["branches"]
assert len(branches["nodes"]) == 3
- assert branches["edges"][0]["cursor"] == end_cursor
+ # assert branches["edges"][0]["cursor"] == end_cursor
for node in branches["nodes"]:
assert node["name"]["text"] > node_name
diff --git a/swh/graphql/tests/functional/test_pagination.py b/swh/graphql/tests/functional/test_pagination.py
--- a/swh/graphql/tests/functional/test_pagination.py
+++ b/swh/graphql/tests/functional/test_pagination.py
@@ -4,7 +4,7 @@
# See top-level LICENSE file for more information
from . import utils
-from ..data import get_origins
+from ..data import get_directories, get_origins
# Using Origin object to run functional tests for pagination
@@ -78,26 +78,69 @@
def test_edge_cursor(client):
- origins = get_origin_nodes(client, first=1)[0]["origins"]
- # end cursor here must be the item cursor for the second item
- end_cursor = origins["pageInfo"]["endCursor"]
-
+ # Use DirectoryEntry connection to test connection edges
+ # The same code is used in all the other connections, hence a single test
+ directory = get_directories()[1]
query_str = """
- query getOrigins($first: Int!, $after: String) {
- origins(first: $first, after: $after) {
- edges {
- cursor
- node {
- id
+ query getDirectory($swhid: SWHID!, $entries_first: Int!, $entries_after: String) {
+ directory(swhid: $swhid) {
+ entries(first: $entries_first, after: $entries_after) {
+ edges {
+ cursor
+ node {
+ name {
+ text
+ }
+ }
+ }
+ pageInfo {
+ endCursor
+ hasNextPage
+ }
+ nodes {
+ name {
+ text
+ }
}
- }
- nodes {
- id
}
}
}
"""
- data, _ = utils.get_query_response(client, query_str, first=1, after=end_cursor)
- origins = data["origins"]
- assert [edge["node"] for edge in origins["edges"]] == origins["nodes"]
- assert origins["edges"][0]["cursor"] == end_cursor
+ data, _ = utils.get_query_response(
+ client, query_str, swhid=str(directory.swhid()), entries_first=1
+ )
+ entries = data["directory"]["entries"]
+ # Make sure the first node object in edges and nodes is the same
+ assert entries["edges"][0]["node"] == entries["nodes"][0]
+ assert entries["edges"][0]["node"] == {
+ "name": {"text": directory.entries[1].name.decode()}
+ }
+ assert entries["pageInfo"]["hasNextPage"] is True
+ # FIXME, Following behaviour is not in compliance with the relay spec.
+ # last-item-cursor and endcursor will be the same in relay.
+ # This test will fail once the pagination becomes fully relay complaint
+ assert not entries["pageInfo"]["endCursor"] == entries["edges"][-1]["cursor"]
+ # Make another query with the after argument, after argument is the first item
+ # cursor here, result will be the same as the last one
+ new_data, _ = utils.get_query_response(
+ client,
+ query_str,
+ swhid=str(directory.swhid()),
+ entries_first=1,
+ entries_after=entries["edges"][0]["cursor"],
+ )
+ assert new_data == data
+ # Make another query with the end cursor from the first query
+ final_data, _ = utils.get_query_response(
+ client,
+ query_str,
+ swhid=str(directory.swhid()),
+ entries_first=1,
+ entries_after=entries["pageInfo"]["endCursor"],
+ )
+ # last endcursor will be the first item cursor here
+ # FIXME, this behaviour is not in compliance with the relay spec.
+ assert (
+ final_data["directory"]["entries"]["edges"][0]["cursor"]
+ == entries["pageInfo"]["endCursor"]
+ )
diff --git a/swh/graphql/tests/functional/test_visit_status.py b/swh/graphql/tests/functional/test_visit_status.py
--- a/swh/graphql/tests/functional/test_visit_status.py
+++ b/swh/graphql/tests/functional/test_visit_status.py
@@ -53,7 +53,6 @@
endCursor
}
edges {
- cursor
node {
status
}
@@ -76,7 +75,6 @@
endCursor
}
edges {
- cursor
node {
status
}
@@ -95,7 +93,7 @@
assert data["visit"]["statuses"] == {
"edges": [
{
- "cursor": "MjAxNC0wNS0wN1QwNDoyMDozOS40MzIyMjIrMDA6MDA=",
+ # "cursor": "MjAxNC0wNS0wN1QwNDoyMDozOS40MzIyMjIrMDA6MDA=",
"node": {"status": "ongoing"},
}
],
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 3:28 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3225906
Attached To
D8911: Remove ambiguous item cursors
Event Timeline
Log In to Comment