diff --git a/client.ts b/client.ts index 4a4ac51..ffc6cdd 100644 --- a/client.ts +++ b/client.ts @@ -680,8 +680,6 @@ export class OpenFgaClient extends BaseAPI { maxParallelRequests = DEFAULT_MAX_METHOD_PARALLEL_REQS, } = options; - // TODO this right? Do it here? - setHeaderIfNotSet(headers, CLIENT_METHOD_HEADER, "BatchCheck"); setHeaderIfNotSet(headers, CLIENT_BULK_REQUEST_ID_HEADER, generateRandomIdWithNonUniqueFallback()); const correlationIdToCheck = new Map(); @@ -725,7 +723,7 @@ export class OpenFgaClient extends BaseAPI { consistency: options.consistency, }; - const response = await this.singleBatchCheck(batchRequest, options); + const response = await this.singleBatchCheck(batchRequest, { ...options, headers }); return response.result; }); diff --git a/tests/client.test.ts b/tests/client.test.ts index 243d3eb..8dc9964 100644 --- a/tests/client.test.ts +++ b/tests/client.test.ts @@ -598,7 +598,8 @@ describe("OpenFGA Client", () => { }, }, }; - const scope = nocks.singleBatchCheck(baseConfig.storeId!, mockedResponse, undefined, ConsistencyPreference.HigherConsistency, "01GAHCE4YVKPQEKZQHT2R89MQV"); + + const scope = nocks.singleBatchCheck(baseConfig.storeId!, mockedResponse, undefined, ConsistencyPreference.HigherConsistency, "01GAHCE4YVKPQEKZQHT2R89MQV").matchHeader("X-OpenFGA-Client-Bulk-Request-Id", /.*/); expect(scope.isDone()).toBe(false); const response = await fgaClient.batchCheck({ @@ -661,8 +662,8 @@ describe("OpenFGA Client", () => { }, }; - const scope0 = nocks.singleBatchCheck(baseConfig.storeId!, mockedResponse0, undefined, ConsistencyPreference.HigherConsistency, "01GAHCE4YVKPQEKZQHT2R89MQV"); - const scope1 = nocks.singleBatchCheck(baseConfig.storeId!, mockedResponse1, undefined, ConsistencyPreference.HigherConsistency, "01GAHCE4YVKPQEKZQHT2R89MQV"); + const scope0 = nocks.singleBatchCheck(baseConfig.storeId!, mockedResponse0, undefined, ConsistencyPreference.HigherConsistency, "01GAHCE4YVKPQEKZQHT2R89MQV").matchHeader("X-OpenFGA-Client-Bulk-Request-Id", /.*/); + const scope1 = nocks.singleBatchCheck(baseConfig.storeId!, mockedResponse1, undefined, ConsistencyPreference.HigherConsistency, "01GAHCE4YVKPQEKZQHT2R89MQV").matchHeader("X-OpenFGA-Client-Bulk-Request-Id", /.*/); expect(scope0.isDone()).toBe(false); expect(scope1.isDone()).toBe(false);