Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks
rhamzeh opened this issue Feb 1, 2024 · 0 comments
Assignees
Labels
dotnet-sdk Affects the C#/DotNet SDK enhancement New feature or request go-sdk Affects the Go SDK good first issue Good for newcomers java-sdk Affects the Java/Kotlin SDK js-sdk Affects the JavaScript SDK python-sdk Affects the Python SDK

Comments

@rhamzeh
Copy link
Member

rhamzeh commented Feb 1, 2024

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()
  • JS SDK
  • Go SDK
  • .NET SDK
  • Python SDK
  • Java SDK
@rhamzeh rhamzeh added enhancement New feature or request good first issue Good for newcomers go-sdk Affects the Go SDK dotnet-sdk Affects the C#/DotNet SDK js-sdk Affects the JavaScript SDK python-sdk Affects the Python SDK java-sdk Affects the Java/Kotlin SDK labels Feb 1, 2024
@ewanharris ewanharris self-assigned this Feb 8, 2024
srose added a commit to srose/sdk-generator that referenced this issue Feb 8, 2024
@rhamzeh rhamzeh moved this to In progress in SDKs and Tooling Feb 9, 2024
github-merge-queue bot pushed a commit to openfga/dotnet-sdk that referenced this issue Feb 12, 2024
…44)

## Description

Adds the `Deletes` property to the test to ensure that we don't pass
this when it is empty. Given that we don't match on body this isn't
really much gain but it will help to ensure we maintain this in future
if we improve testing.

## References

Part of openfga/sdk-generator#299
Generated from openfga/sdk-generator#306

## Review Checklist
- [x] I have clicked on ["allow edits by
maintainers"](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
- [ ] I have added documentation for new/changed functionality in this
PR or in a PR to [openfga.dev](https://github.com/openfga/openfga.dev)
[Provide a link to any relevant PRs in the references section above]
- [x] 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
@ewanharris ewanharris moved this from In progress to Done in SDKs and Tooling Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-sdk Affects the C#/DotNet SDK enhancement New feature or request go-sdk Affects the Go SDK good first issue Good for newcomers java-sdk Affects the Java/Kotlin SDK js-sdk Affects the JavaScript SDK python-sdk Affects the Python SDK
Projects
Status: Done
Development

No branches or pull requests

2 participants