feat: support contextual tuples in expand request
Review Checklist
- [x] 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 - [x] I have added tests to validate that the change in functionality is working as expected
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: SoulPancake / name: Anurag Bandyopadhyay (78205dbe6edc15e3bdbbb87413bd82944f8f9988)
- :white_check_mark: login: rhamzeh / name: Raghd Hamzeh (4433677c8826ff72bb391e13e5ef5f3b2e2ce077, 96c155e658156376f4506529fd626c5defcb8a8b, 9c2ee3999a0c96f479f7f2f7783abf8d370ed344, 6f30088fe78ccc835b38b2a12ace042d7ab57655)
@rhamzeh Are the failing tests anything related to my changes? I guess not because the mirrored changes work totally fine in the sdk repo
[!IMPORTANT]
Review skipped
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
Adds contextual tuple support to the Go client’s Expand request by introducing a ContextualTuples field to ClientExpandRequest, propagating it through ExpandExecute via fgaSdk.NewContextualTupleKeys, and updating tests to validate the request body includes contextual_tuples and response handling.
Changes
| Cohort / File(s) | Summary |
|---|---|
Go client Expand implementationconfig/clients/go/template/client/client.mustache |
Added ClientExpandRequest.ContextualTuples field and logic in Expand flow to collect contextual tuples from request body, convert to SDK contextual tuple keys, and attach to the outgoing ExpandRequest. Existing relation/object handling unchanged. |
Go client tests for Expandconfig/clients/go/template/client/client_test.mustache |
Added test ExpandWithContextualTuples that sends contextual tuples via Expand, asserts request contains contextual_tuples, and verifies response marshaling. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant App as Caller
participant GoClient as Go Client (Expand)
participant SDK as fgaSdk
participant API as OpenFGA API
App->>GoClient: Expand(ClientExpandRequest{..., ContextualTuples})
GoClient->>GoClient: Collect contextual tuples from request body
GoClient->>SDK: NewContextualTupleKeys(contextualTuples)
SDK-->>GoClient: ContextualTupleKeys
GoClient->>API: ExpandRequest{..., contextual_tuple_keys}
API-->>GoClient: ExpandResponse
GoClient-->>App: ExpandResponse
note over GoClient,API: Control flow unchanged aside from attaching contextual tuples
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related issues
- openfga/go-sdk#201 — Implements client-side support for ContextualTuples in Expand, matching the added field and mapping in this PR.
✨ Finishing touches
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.