openfga / sdk-generator

OpenFGA Client SDK Generator
Apache License 2.0
14 stars 30 forks source link

[All SDKs] Allow `writes` and `deletes` to accept empty arrays, but do not forward them to the server #299

Open rhamzeh opened 5 months ago

rhamzeh commented 5 months ago

The API currently enforces array lengths to be at least 1 when sent. source

On the SDK side, this provides a subpar developer experience.

Considering OpenFgaClient already wraps the API client, we should allow empty arrays, but do not send them to the server to improve the experience of users using the SDK so that they do not worry about this.

The idea is not to have the app short circuit when both Writes and Deletes are not provided, instead we want to add test and ensure that if they are an empty array, they are not sent (as fields) to the API.

So: OpenFgaClient User Request Sent to the API
Write(writes=[tupleA], deletes=[tupleB]) Write(writes=[tupleA], deletes=[tupleB])
Write(writes=[], deletes=[tupleA]) Write(deletes=[tupleA])
Write(writes=[tupleA, deletes=[]) Write(writes=[tupleA])
Write(writes=[], deletes=[]) Write()