feat: add APIExecutor dedicated examples#385
Conversation
WalkthroughAdds a new "API Executor" example demonstrating low-level SDK methods ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #385 +/- ##
=======================================
Coverage 85.79% 85.79%
=======================================
Files 26 26
Lines 1267 1267
Branches 249 225 -24
=======================================
Hits 1087 1087
Misses 110 110
Partials 70 70 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new runnable example under example/api-executor/ to demonstrate using OpenFgaClient’s low-level executeApiRequest and executeStreamedApiRequest APIs, including an NDJSON streaming workflow.
Changes:
- Added
api-executorexample script exercising multiple OpenFGA endpoints via the generic request executors (including streaming). - Added dedicated README for the new example with setup/run instructions and usage notes.
- Updated the examples index README to mention the new API Executor example.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| example/api-executor/package.json | Defines the new example’s Node entrypoint, dependency wiring, and runtime constraints. |
| example/api-executor/apiExecutor.mjs | End-to-end example invoking OpenFGA endpoints via executeApiRequest / executeStreamedApiRequest. |
| example/api-executor/README.md | Documentation for when/how to use the low-level executor APIs and how to run the demo. |
| example/README.md | Adds a short description of the new example to the examples list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
example/api-executor/apiExecutor.mjs (1)
29-34: Avoid exiting insidehandleError; it can skip cleanup.
process.exit(1)on Line 33 bypasses the normal control flow, so failures after store creation can leave test stores undeleted. Prefer throwing and doing best-effort delete infinally.Also applies to: 332-341
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@example/api-executor/apiExecutor.mjs` around lines 29 - 34, The handleError function should not call process.exit(1); instead, remove the process.exit call and rethrow the error (or throw a new Error with context) so callers can perform cleanup; update any other error-handler occurrences noted (the similar block at lines 332-341) to follow the same pattern and ensure callers wrap operations that create test stores in try/catch/finally where the finally block attempts best-effort deletion of created stores (log failures but do not hard-exit).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@example/api-executor/package.json`:
- Line 3: The package.json currently sets the "private" field as a string
("true"); change it to a boolean (true) so npm treats it correctly and prevents
accidental publish — locate the "private" entry in package.json and replace the
string value with the boolean literal true.
In `@example/api-executor/README.md`:
- Around line 125-170: The README's multi-line example block is missing a
language tag which triggers MD040; update the fenced code block in
example/api-executor/README.md (the OpenFGA executeApiRequest Example block) to
include a language identifier such as text or bash by changing the opening ```
to ```text (or ```bash) so markdownlint no longer flags it.
---
Nitpick comments:
In `@example/api-executor/apiExecutor.mjs`:
- Around line 29-34: The handleError function should not call process.exit(1);
instead, remove the process.exit call and rethrow the error (or throw a new
Error with context) so callers can perform cleanup; update any other
error-handler occurrences noted (the similar block at lines 332-341) to follow
the same pattern and ensure callers wrap operations that create test stores in
try/catch/finally where the finally block attempts best-effort deletion of
created stores (log failures but do not hard-exit).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2bd78af5-590e-4c85-bd9e-17dc4aed6ee1
📒 Files selected for processing (4)
example/README.mdexample/api-executor/README.mdexample/api-executor/apiExecutor.mjsexample/api-executor/package.json
Description
What problem is being solved?
How is it being solved?
What changes are made to solve it?
References
Review Checklist
mainSummary by CodeRabbit
Release Notes