Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Outline

Examples of using the OpenFGA JS SDK

A set of Examples on how to call the OpenFGA JS SDK

Examples

Example 1: A bare-bones example. It creates a store and runs a set of calls against it including creating a model, writing tuples, and checking for access.

OpenTelemetry: An example that demonstrates how to integrate the OpenFGA JS SDK with OpenTelemetry.

API Executor: Demonstrates how to use the low-level executeApiRequest and executeStreamedApiRequest methods to call OpenFGA endpoints directly — both standard request/response and streaming. Useful when calling new, experimental, or custom endpoints not yet wrapped by the SDK.

Running the Examples

Prerequisites:

  • docker
  • make
  • Node.js 16.13.0+

Run using a published SDK

Steps

  1. Clone/Copy the example folder
  2. If you have an OpenFGA server running, you can use it, otherwise run make run-openfga to spin up an instance (you'll need to switch to a different terminal after - don't forget to close it when done)
  3. Run make setup to install dependencies
  4. Run make run to run the example

Run using a local unpublished SDK build

Steps

  1. Build the SDK
  2. In the Example package.json change the @openfga/sdk dependency from a semver range like below
"dependencies": {
    "@openfga/sdk": "^0.9.4"
  }

to a file: reference like below

"dependencies": {
    "@openfga/sdk": "file:../../"
  }
  1. If you have an OpenFGA server running, you can use it, otherwise run make run-openfga to spin up an instance (you'll need to switch to a different terminal after - don't forget to close it when done)
  2. Run make setup to install dependencies
  3. Run make run to run the example
Morty Proxy This is a proxified and sanitized view of the page, visit original site.