From 9ef9785a3af0ed84778a16a77ef6f8e8d788b59c Mon Sep 17 00:00:00 2001 From: Thiago Bellini Ribeiro Date: Wed, 22 Nov 2023 19:34:52 -0300 Subject: [PATCH] docs: add some TODO comments for the future --- src/strawberry_sqlalchemy_mapper/relay.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/strawberry_sqlalchemy_mapper/relay.py b/src/strawberry_sqlalchemy_mapper/relay.py index a6b6535..1960b9b 100644 --- a/src/strawberry_sqlalchemy_mapper/relay.py +++ b/src/strawberry_sqlalchemy_mapper/relay.py @@ -134,6 +134,8 @@ def resolve_nodes(s: Session, nodes=nodes): ) ) + # TODO: It would be better to aboid session.run_sync in here but + # sqlakeyset doesn't have a `get_page` async counterpart. if isinstance(session, AsyncSession): async def resolve_async(nodes=nodes): @@ -366,6 +368,8 @@ def resolve_model_node( try: return results.one() except NoResultFound: + # If returning a single result fails, return `None` if this wasn't + # required, otherwise reraise the exception if not required: return None @@ -411,4 +415,6 @@ def resolve_model_id( id_attr = cast(relay.Node, source).resolve_id_attr().split("|") assert id_attr + # TODO: Maybe we can work with the tuples directly in the future? + # We would need to add support on strawberry for that first though. return "|".join(str(getattr(root, k)) for k in id_attr)