Skip to content

feat!: support for request options - #36

Open
bojan88 wants to merge 9 commits into
mainfrom
req-options-support
Open

feat!: support for request options#36
bojan88 wants to merge 9 commits into
mainfrom
req-options-support

Conversation

@bojan88

@bojan88 bojan88 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

BREAKING CHANGE: headers are moved to 2nd argument in .get, .post, etc. methods.

Instead of .get({ query, headers }) we now have .get({ query }, { headers, signal, ... }).
Before this change we could only pass headers and other options like abort signal for example were not supported.

One option to test this is to run npm run pack and install the produced package in your local project.

@bojan88
bojan88 force-pushed the req-options-support branch 7 times, most recently from 089a47d to 1d3895c Compare August 12, 2026 16:17
Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
Assisted-by: GitHub Copilot
Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
Assisted-by: GitHub Copilot
Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
@bojan88
bojan88 force-pushed the req-options-support branch from 1d3895c to 46fe557 Compare August 12, 2026 16:24
Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
@bojan88
bojan88 force-pushed the req-options-support branch from 6a08fac to 4cbee7a Compare August 14, 2026 13:48
Comment thread src/postgrest-client.ts
const { base, axiosInstance, encodeQueryStrings } = config;
/* c8 ignore next 3 */
if (!this.#axiosInstance && typeof fetch !== 'function') {
if (!axiosInstance && typeof fetch !== 'function') {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't part of this feature, but it was incorrect

Comment thread src/postgrest-client.ts
} = await this.#axiosInstance[
method.toLowerCase() as Lowercase<Method>
](url, requestData, {
...(reqOptions as AxiosRequestConfig),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type here couldn't be narrower based on Client generic, so it's either casting here or having a type guard like isAxiosClient(reqOptions): reqOptions is AxiosRequestConfig | undefined => !!this.#axiosInstance

Comment thread src/postgrest-client.ts
}

const fetchResponse = await fetch(url, {
...(reqOptions as RequestInit),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as comment above, and we have more occurrences bellow.

// @ts-expect-error testing missing name
.select([
pgClient.embeddedQuery('directors', 'one').select('*'),
// @ts-expect-error testing missing name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change came from typescript upgrade.
The reason for the upgrade were incorrectly flagged errors for headers?.entries() bellow - the old version of typescript is not aware of .entries() method on Headers class

Signed-off-by: Bojan Đurđević <bojan88@gmail.com>
@bojan88
bojan88 marked this pull request as ready for review August 14, 2026 15:23
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.

2 participants