Skip to content

Commit 422e2f1

Browse files
committed
check if cursor is repeated
1 parent 2c637ee commit 422e2f1

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

ayon_api/exceptions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ class HTTPRequestError(RequestError):
7878
pass
7979

8080

81-
class GraphQlQueryFailed(Exception):
81+
class GraphQlQueryError(Exception):
82+
pass
83+
84+
85+
class GraphQlQueryFailed(GraphQlQueryError):
8286
def __init__(self, errors, query, variables):
8387
if variables is None:
8488
variables = {}

ayon_api/graphql.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import typing
77
from typing import Optional, Iterable, Any, Generator
88

9-
from .exceptions import GraphQlQueryFailed
9+
from .exceptions import GraphQlQueryError, GraphQlQueryFailed
1010
from .utils import SortOrder
1111

1212
if typing.TYPE_CHECKING:
@@ -947,6 +947,11 @@ def parse_result(
947947
if change_cursor:
948948
for child in self._children_iter():
949949
child.reset_cursor()
950+
if new_cursor == self._cursor:
951+
raise GraphQlQueryError(
952+
"Cursor didn't change during pagination."
953+
" This can cause infinite loop."
954+
)
950955
self._cursor = new_cursor
951956

952957
def _get_cursor_key(self) -> str:

0 commit comments

Comments
 (0)