File tree Expand file tree Collapse file tree 5 files changed +467
-124
lines changed Expand file tree Collapse file tree 5 files changed +467
-124
lines changed Original file line number Diff line number Diff line change 33 build_openfga_client ,
44 build_openfga_client_sync ,
55)
6- from pydantic import PrivateAttr
76from openfga_sdk import ClientConfiguration
87from openfga_sdk .client .models import ClientBatchCheckItem
98from openfga_sdk .client .client import ClientBatchCheckRequest
109
1110
1211class FGAFilter [T ]:
13- _query_builder : Callable [[T ], ClientBatchCheckItem ] = PrivateAttr ()
12+ _query_builder : Callable [[T ], ClientBatchCheckItem ]
1413 _fga_configuration : Optional [ClientConfiguration ]
1514
1615 def __init__ (
@@ -43,6 +42,9 @@ async def filter(
4342 Returns:
4443 List[T]: Filtered list of documents authorized by FGA.
4544 """
45+ if len (documents ) == 0 :
46+ return []
47+
4648 async with build_openfga_client (self ._fga_configuration ) as fga_client :
4749 all_checks = [self ._query_builder (doc ) for doc in documents ]
4850 unique_checks = list (
@@ -94,6 +96,9 @@ def filter_sync(
9496 Returns:
9597 List[T]: Filtered list of documents authorized by FGA.
9698 """
99+ if len (documents ) == 0 :
100+ return []
101+
97102 with build_openfga_client_sync (self ._fga_configuration ) as fga_client :
98103 all_checks = [self ._query_builder (doc ) for doc in documents ]
99104 unique_checks = list (
You can’t perform that action at this time.
0 commit comments