We currently require passing an object with type as an empty string when calling the OpenFgaClient.readChanges, this is because we do not mark the body param as optional, when in reality it is as it is not required to pass a type to the api, and based on our other SDKs this seems a perfectly valid usage.
This is only really obvious when using TypeScript as it will flag the issue, developers who aren't using TypeScript won't see anything wrong until their code runs and the SDK errors when trying to access body.type.
const response = await fgaClient.readChanges(); // Expected 1-2 arguments, but got 0. An argument for 'body' was not provided.
This PR proposes moving the body parameter to be optional, meaning that the above is now valid from a typechecking perspective and guards the property access so no runtime errors occur
References
I'll make the JS SDK PR once this if this change gets OK'd
[ ] I have added documentation for new/changed functionality in this PR or in a PR to 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
Description
We currently require passing an object with
type
as an empty string when calling theOpenFgaClient.readChanges
, this is because we do not mark thebody
param as optional, when in reality it is as it is not required to pass atype
to the api, and based on our other SDKs this seems a perfectly valid usage.This is only really obvious when using TypeScript as it will flag the issue, developers who aren't using TypeScript won't see anything wrong until their code runs and the SDK errors when trying to access
body.type
.This PR proposes moving the
body
parameter to be optional, meaning that the above is now valid from a typechecking perspective and guards the property access so no runtime errors occurReferences
I'll make the JS SDK PR once this if this change gets OK'd
Review Checklist
main