openfga / roadmap

OpenFGA Public Roadmap
2 stars 0 forks source link

ListRelations support in SDKs #26

Closed aaguiarz closed 1 year ago

aaguiarz commented 1 year ago

Developers want to have a simple way to know which relations a user has with a specific object.

To build the UI below:

image

developers could use the Read endpoint if all of those relations are direct relations. However, if some of them are indirect relations, they'll need to call Check for each one.

To simplify this use case, we can provide an API like

const response = await fgaClient.listRelations({
  users: "user:123"
  object: "document:pricing"
  relations: ["can_view", "can_edit"]
});

// returns response.relations : [ "can_view"]

This API can be implemented on the SDKs, by calling multiple checks in Batch, or in the server. We'll start by implementing it in the client to better understand its value/usage, and eventually implement it in the server later.