Skip to content

Commit fc80f6d

Browse files
committed
add missing page_info / cursors for relay
1 parent 2133fd7 commit fc80f6d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/strawberry_sqlalchemy_mapper/mapper.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
SkipTypeSentinelT = NewType("SkipTypeSentinelT", object)
104104
SkipTypeSentinel = cast(SkipTypeSentinelT, sentinel.create("SkipTypeSentinel"))
105105

106-
107106
#: Set on generated types to the original type handed to the decorator
108107
_ORIGINAL_TYPE_KEY = "_original_type"
109108
#: Set on generated types, containing the list of keys of fields that were generated
@@ -387,7 +386,7 @@ def _convert_relationship_to_strawberry_type(
387386
if relationship.uselist:
388387
# Use list if excluding relay pagination
389388
if use_list:
390-
return List[ForwardRef(type_name)] # type: ignore
389+
return List[ForwardRef(type_name)] # type: ignore
391390

392391
return self._connection_type_for(type_name)
393392
else:
@@ -572,7 +571,12 @@ async def resolve(self, info: Info):
572571
in_between_objects = await in_between_resolver(self, info)
573572
if in_between_objects is None:
574573
if is_multiple:
575-
return connection_type(edges=[])
574+
return connection_type(edges=[], page_info=relay.PageInfo(
575+
has_next_page=False,
576+
has_previous_page=False,
577+
start_cursor=None,
578+
end_cursor=None,
579+
))
576580
else:
577581
return None
578582
if descriptor.value_attr in in_between_mapper.relationships:
@@ -592,7 +596,14 @@ async def resolve(self, info: Info):
592596
outputs = await end_relationship_resolver(in_between_objects, info)
593597
if not isinstance(outputs, collections.abc.Iterable):
594598
return outputs
595-
return connection_type(edges=[edge_type(node=obj) for obj in outputs])
599+
edges = [edge_type(node=obj) for obj in outputs]
600+
return connection_type(edges=edges,
601+
page_info=relay.PageInfo(
602+
has_next_page=False,
603+
has_previous_page=False,
604+
start_cursor=edges[0].cursor if edges else None,
605+
end_cursor=edges[-1].cursor if edges else None,
606+
))
596607
else:
597608
assert descriptor.value_attr in in_between_mapper.columns
598609
if isinstance(in_between_objects, collections.abc.Iterable):

0 commit comments

Comments
 (0)