Skip to content

Commit

Permalink
fix client headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjames committed Dec 17, 2024
1 parent c587a9a commit 4637704
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ClientBatchCheckItem>();
Expand Down Expand Up @@ -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;
});

Expand Down
7 changes: 4 additions & 3 deletions tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4637704

Please sign in to comment.