From d810d957dc27172f8c9453d1ddff34e4c6d52a92 Mon Sep 17 00:00:00 2001 From: Jeffrey Lo Date: Thu, 12 Feb 2026 08:34:38 -1000 Subject: [PATCH] connection: align remaining PageInfoType members as properties This patch adds the `@property` decorator to `endCursor`, `hasPreviousPage`, and `hasNextPage` in the `PageInfoType` Protocol. Previously, only `startCursor` was defined as a property, creating an inconsistency where other members appeared as callable methods. The `PageInfo` implementation exposes these fields as attributes, not methods. Correctly marking them as properties in the Protocol ensures static analysis and IDEs reflect the actual usage. --- src/graphql_relay/connection/connection.py | 3 +++ tests/connection/test_connection.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/graphql_relay/connection/connection.py b/src/graphql_relay/connection/connection.py index 2058baa..3321353 100644 --- a/src/graphql_relay/connection/connection.py +++ b/src/graphql_relay/connection/connection.py @@ -152,12 +152,15 @@ class PageInfoType(Protocol): def startCursor(self) -> Optional[ConnectionCursor]: ... + @property def endCursor(self) -> Optional[ConnectionCursor]: ... + @property def hasPreviousPage(self) -> bool: ... + @property def hasNextPage(self) -> bool: ... diff --git a/tests/connection/test_connection.py b/tests/connection/test_connection.py index 025cb2d..39a92f4 100644 --- a/tests/connection/test_connection.py +++ b/tests/connection/test_connection.py @@ -17,6 +17,7 @@ connection_definitions, connection_from_array, forward_connection_args, + PageInfoType, ) from ..utils import dedent @@ -98,6 +99,17 @@ class User(NamedTuple): schema = GraphQLSchema(query=query_type) +def describe_page_info_type(): + def defines_all_members_as_properties(): + for member_name in ( + "startCursor", + "endCursor", + "hasPreviousPage", + "hasNextPage", + ): + assert type(getattr(PageInfoType, member_name)) is property + + def describe_connection_definition(): def includes_connection_and_edge_fields(): source = """