Skip to content

docs: parse raw stream#389

Merged
SoulPancake merged 3 commits into
mainfrom
chore/parserawstream-doc
Apr 27, 2026
Merged

docs: parse raw stream#389
SoulPancake merged 3 commits into
mainfrom
chore/parserawstream-doc

Conversation

@SoulPancake

Copy link
Copy Markdown
Member

Description

What problem is being solved?

How is it being solved?

What changes are made to solve it?

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Copilot AI review requested due to automatic review settings April 20, 2026 14:54
@SoulPancake
SoulPancake requested review from a team as code owners April 20, 2026 14:54
@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@SoulPancake has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 11 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 59 minutes and 11 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e035231-7832-4d87-86a1-eac00f6f4814

📥 Commits

Reviewing files that changed from the base of the PR and between 2668838 and 778d564.

📒 Files selected for processing (1)
  • README.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/parserawstream-doc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot

dosubot Bot commented Apr 20, 2026

Copy link
Copy Markdown

Documentation Updates

1 document(s) were updated by changes in this PR:

StreamedListObjects Feature Overview
View Changes
@@ -178,7 +178,7 @@
 
 Additionally, the JS SDK provides `executeApiRequest` and `executeStreamedApiRequest` methods on `OpenFgaClient` that can be used to call arbitrary API endpoints that don't yet have dedicated SDK methods. Use `executeApiRequest` for regular endpoints and `executeStreamedApiRequest` for streaming endpoints like `/streamed-list-objects`. These methods act as an escape hatch while still providing SDK benefits like authentication, configuration, retries, and error handling.
 
-**Example:**
+**Example (Non-Streaming Endpoint):**
 ```javascript
 const response = await fgaClient.executeApiRequest({
   operationName: 'CustomEndpoint',  // Required: operation name for telemetry
@@ -191,6 +191,40 @@
 });
 ```
 
+**Example (Streaming Endpoint):**
+
+For streaming endpoints, use `executeStreamedApiRequest` instead of `executeApiRequest`. This returns a raw Node.js readable stream. To parse the newline-delimited JSON (NDJSON) response into individual objects, use the `parseNDJSONStream` helper exported by the SDK:
+
+```javascript
+const { OpenFgaClient, parseNDJSONStream } = require('@openfga/sdk');
+
+const fgaClient = new OpenFgaClient({
+  apiUrl: process.env.FGA_API_URL,
+  storeId: process.env.FGA_STORE_ID,
+});
+
+const streamResponse = await fgaClient.executeStreamedApiRequest({
+  operationName: 'StreamedListObjects',
+  method: 'POST',
+  path: '/stores/{store_id}/streamed-list-objects',
+  pathParams: { store_id: process.env.FGA_STORE_ID },
+  body: {
+    authorization_model_id: process.env.FGA_MODEL_ID,
+    user: 'user:alice',
+    relation: 'reader',
+    type: 'document',
+  },
+});
+
+// executeStreamedApiRequest returns the raw Node.js Readable stream directly.
+// Use parseNDJSONStream to iterate over the parsed JSON objects:
+for await (const item of parseNDJSONStream(streamResponse)) {
+  console.log('Object:', item.object);
+}
+```
+
+Unlike `executeApiRequest` (which wraps the response in a `CallResult` with a `$response` property), `executeStreamedApiRequest` returns the raw stream directly. `parseNDJSONStream` handles chunked data, partial lines, and buffer flushing automatically. It accepts Node.js `Readable` streams, `AsyncIterable`s, or even plain strings and `Buffer`s.
+
 ### .NET SDK
 The .NET SDK provides `ApiExecutor` for calling custom API endpoints, including `/streamed-list-objects`. Use the `ExecuteStreamingAsync` method to stream results as they arrive without pagination limits.
 

How did I do? Any feedback?  Join Discord

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.79%. Comparing base (2668838) to head (778d564).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #389   +/-   ##
=======================================
  Coverage   85.79%   85.79%           
=======================================
  Files          26       26           
  Lines        1267     1267           
  Branches      225      225           
=======================================
  Hits         1087     1087           
  Misses        110      110           
  Partials       70       70           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds README documentation for consuming streaming endpoints via executeStreamedApiRequest, including parsing NDJSON output with the SDK’s parseNDJSONStream helper.

Changes:

  • Document how to call a streaming endpoint using executeStreamedApiRequest.
  • Add a JavaScript example showing NDJSON parsing with parseNDJSONStream.
  • Clarify behavioral differences between executeApiRequest and executeStreamedApiRequest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment thread README.md
Comment thread README.md
@SoulPancake
SoulPancake added this pull request to the merge queue Apr 27, 2026
Merged via the queue into main with commit 7331c56 Apr 27, 2026
23 checks passed
@SoulPancake
SoulPancake deleted the chore/parserawstream-doc branch April 27, 2026 15:02
@openfga-releaser-bot openfga-releaser-bot Bot mentioned this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants