openfga / dotnet-sdk

OpenFGA SDK for .NET - https://www.nuget.org/packages/OpenFga.Sdk
https://openfga.dev
Apache License 2.0
42 stars 3 forks source link

Provide client service through interfaces to improve decoupling and testability of client application #56

Open bubianchi-criteo opened 2 months ago

bubianchi-criteo commented 2 months ago

Checklist

Describe the problem you'd like to have solved

I'm prototyping an application that leverages this very useful SDK. To develop our unit tests of my application code, I could not easily simulate and mock specific behaviors in particular for error cases because the OpenFgaClient is provided as a class without overridable methods.

Describe the ideal solution

We could improve the SDK extensibility and client application testability by providing features through interfaces, in particular a IOpenFgaClient interface with the public methods implemented by OpenFgaClient. Moreover the actual construction of the OpenFga client could be managed through a factory pattern, and with its own interface would enable using natively Dependency Injection from AspNet

Alternatives and current workarounds

No response

References

No response

Additional context

No response

rhamzeh commented 2 months ago

Thanks for the suggestion @bubianchi-criteo - added to our backlog. Feel free to contribute the change if you are willing!