Skip to content

Conversation

@ewanharris
Copy link
Member

@ewanharris ewanharris commented Jul 19, 2024

Description

This is an initial attempt at introducing support for the experimental consistency option in the relevant APIs, this is supported on the following APIs:

  • Check
  • List Users
  • List Objects + Streamed List Objects
  • Expand
  • Read

And the following SDK methods

  • listRelations
  • batchCheck

When introducing this option to the OpenFGAClient class, we decided that this option fits better in the options object as opposed to the request object as it's more of an "override" choice akin to the existing model ID and store ID.

So the usage looks like so

const { allowed } = await fgaClient.check({
  user: "user:anne",
  relation: "viewer",
  object: "document:roadmap",
}, { consistency: ConsistencyPreference.HigherConsistency });

I think there is a question around the correct usage for batchCheck, in that instance should the consistency choice be per check or for the entire batchCheck, currently we have it for the entire batchCheck but personally I don't think this is ideal.

await fgaClient.batchCheck([{
  user: "user:anne",
  relation: "viewer",
  object: "document:roadmap",
}], { consistency: ConsistencyPreference.HigherConsistency });

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • 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]
  • 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 force-pushed the feat/consistency-options branch from 13b73f7 to 5c3362b Compare July 19, 2024 13:52
@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.13%. Comparing base (78daf78) to head (bacbd79).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #129      +/-   ##
==========================================
+ Coverage   88.08%   88.13%   +0.04%     
==========================================
  Files          19       19              
  Lines         999     1003       +4     
  Branches      149      150       +1     
==========================================
+ Hits          880      884       +4     
  Misses         82       82              
  Partials       37       37              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ewanharris ewanharris force-pushed the feat/consistency-options branch from 5c3362b to bacbd79 Compare July 25, 2024 13:07
@ewanharris ewanharris marked this pull request as ready for review July 25, 2024 13:22
@ewanharris ewanharris requested a review from a team as a code owner July 25, 2024 13:22
@rhamzeh rhamzeh added this pull request to the merge queue Jul 31, 2024
Merged via the queue into main with commit ded34ef Jul 31, 2024
@rhamzeh rhamzeh deleted the feat/consistency-options branch July 31, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants