openfga / sdk-generator

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

fix(js-sdk): make body in readChanges optional #304

Closed ewanharris closed 5 months ago

ewanharris commented 5 months ago

Description

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

Review Checklist