Skip to content

Commit 4f1b5eb

Browse files
docs: add StreamedListObjects documentation
Add documentation for the StreamedListObjects API to the List Objects guide. Changes: - Add Streamed List Objects section explaining streaming differences - Include Node.js and Python SDK examples - Add note about SDK availability - Add related link to StreamedListObjects API reference Related: - openfga/js-sdk#280 - openfga/sdk-generator#654 - openfga/sdk-generator#76
1 parent b4710a2 commit 4f1b5eb

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

docs/content/getting-started/perform-list-objects.mdx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,51 @@ The result `document:otherdoc` and `document:planning` are the document objects
182182
The performance characteristics of the ListObjects endpoint vary drastically depending on the model complexity, number of tuples, and the relations it needs to evaluate. Relations with 'and' or 'but not' are more expensive to evaluate than relations with 'or'.
183183
:::
184184

185+
## Streamed List Objects
186+
187+
The Streamed ListObjects API is similar to the ListObjects API, with two key differences:
188+
189+
1. **Streaming Response**: Instead of collecting all objects before returning a response, it streams them to the client as they are collected.
190+
2. **No Result Limit**: The number of results returned is only limited by the execution timeout specified in the flag `OPENFGA_LIST_OBJECTS_DEADLINE`, not by a fixed limit.
191+
192+
:::info Node.js & Python Only
193+
The streaming functionality is currently available in the **Node.js SDK** and **Python SDK**. Other SDKs return results using the standard ListObjects endpoint.
194+
:::
195+
196+
### Using Streamed List Objects
197+
198+
<Tabs groupId="languages">
199+
<TabItem value={SupportedLanguage.JS_SDK} label={languageLabelMap.get(SupportedLanguage.JS_SDK)}>
200+
201+
```javascript
202+
const objects = [];
203+
for await (const response of fgaClient.streamedListObjects(
204+
{ user: "user:anne", relation: "reader", type: "document" }
205+
)) {
206+
objects.push(response.object);
207+
}
208+
// objects = ["document:otherdoc", "document:planning"]
209+
```
210+
211+
</TabItem>
212+
<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>
213+
214+
```python
215+
objects = []
216+
async for response in fga_client.streamed_list_objects(
217+
ClientListObjectsRequest(
218+
user="user:anne",
219+
relation="reader",
220+
type="document"
221+
)
222+
):
223+
objects.append(response.object)
224+
# objects = ["document:otherdoc", "document:planning"]
225+
```
226+
227+
</TabItem>
228+
</Tabs>
229+
185230
## Related Sections
186231

187232
<RelatedSection
@@ -192,5 +237,10 @@ The performance characteristics of the ListObjects endpoint vary drastically dep
192237
description: 'Read the List Objects API documentation and see how it works.',
193238
link: '/api/service#Relationship%20Queries/ListObjects',
194239
},
240+
{
241+
title: '{ProductName} Streamed List Objects API',
242+
description: 'Read the Streamed List Objects API documentation.',
243+
link: '/api/service#Relationship%20Queries/StreamedListObjects',
244+
},
195245
]}
196246
/>

0 commit comments

Comments
 (0)