Skip to content

Commit

Permalink
Make PageInfo relay schema federation shareable
Browse files Browse the repository at this point in the history
  • Loading branch information
dusty-phillips committed Nov 1, 2023
1 parent 63594fe commit e9d1261
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion strawberry/relay/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from strawberry.object_type import interface, type
from strawberry.private import StrawberryPrivate
from strawberry.relay.exceptions import NodeIDAnnotationError
from strawberry.schema_directive import Location, schema_directive
from strawberry.type import StrawberryContainer, get_object_definition
from strawberry.types.info import Info # noqa: TCH001
from strawberry.types.types import StrawberryObjectDefinition
Expand All @@ -58,6 +59,28 @@
PREFIX = "arrayconnection"


# Copied from federation.schema_directives to avoid depending on that module
@dataclasses.dataclass
class ImportedFrom:
name: str
url: str = "https://specs.apollo.dev/federation/v2.3"


@schema_directive(
locations=[Location.FIELD_DEFINITION, Location.OBJECT],
name="federation__shareable",
repeatable=True,
print_definition=False,
)
class Shareable:
imported_from: ClassVar[ImportedFrom] = ImportedFrom(
name="shareable", url="https://specs.apollo.dev/federation/v2.3"
)
# End copied code




class GlobalIDValueError(ValueError):
"""GlobalID value error, usually related to parsing or serialization."""

Expand Down Expand Up @@ -635,16 +658,20 @@ class PageInfo:
"""

has_next_page: bool = field(
directives=[Shareable()],
description="When paginating forwards, are there more items?",
)
has_previous_page: bool = field(
directives=[Shareable()],
description="When paginating backwards, are there more items?",
)
start_cursor: Optional[str] = field(
directives=[Shareable()],
description="When paginating backwards, the cursor to continue.",
)
end_cursor: Optional[str] = field(
description="When paginating forwards, the cursor to continue.",
directives=[Shareable()],
description="When paginating forwards, the cursor to continue.",
)


Expand Down

0 comments on commit e9d1261

Please sign in to comment.