diff --git a/client/client.go b/client/client.go index 89abd4a..fb70bdc 100644 --- a/client/client.go +++ b/client/client.go @@ -2018,17 +2018,23 @@ func (client *OpenFgaClient) BatchCheckExecute(request SdkClientBatchCheckReques return nil, err } + checkOptions := &ClientCheckOptions{ + AuthorizationModelId: authorizationModelId, + StoreId: storeId, + } + + if request.GetOptions() != nil && request.GetOptions().Consistency != nil { + checkOptions.Consistency = request.GetOptions().Consistency + } + for index, checkBody := range *request.GetBody() { index, checkBody := index, checkBody group.Go(func() error { singleResponse, err := client.CheckExecute(&SdkClientCheckRequest{ - ctx: ctx, - Client: client, - body: &checkBody, - options: &ClientCheckOptions{ - AuthorizationModelId: authorizationModelId, - StoreId: storeId, - }, + ctx: ctx, + Client: client, + body: &checkBody, + options: checkOptions, }) if _, ok := err.(fgaSdk.FgaApiAuthenticationError); ok { diff --git a/client/client_test.go b/client/client_test.go index a9076cb..dbf9474 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -2202,7 +2202,7 @@ func TestOpenFgaClient(t *testing.T) { options := ClientBatchCheckOptions{ AuthorizationModelId: openfga.PtrString(authModelId), MaxParallelRequests: openfga.PtrInt32(5), - Consistency: openfga.CONSISTENCYPREFERENCE_UNSPECIFIED.Ptr(), + Consistency: openfga.CONSISTENCYPREFERENCE_HIGHER_CONSISTENCY.Ptr(), } var expectedResponse openfga.CheckResponse @@ -2213,7 +2213,7 @@ func TestOpenFgaClient(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() httpmock.RegisterMatcherResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, getStoreId(t, fgaClient), test.RequestPath), - httpmock.BodyContainsString(`"consistency":"UNSPECIFIED"`), + httpmock.BodyContainsString(`"consistency":"HIGHER_CONSISTENCY"`), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -2223,10 +2223,16 @@ func TestOpenFgaClient(t *testing.T) { }, ) - _, err := fgaClient.BatchCheck(context.Background()).Body(requestBody).Options(options).Execute() + checks, err := fgaClient.BatchCheck(context.Background()).Body(requestBody).Options(options).Execute() if err != nil { t.Fatalf("%v", err) } + + for _, check := range *checks { + if check.Error != nil { + t.Fatalf("a check failed %v", check.Error) + } + } }) t.Run("Expand", func(t *testing.T) {