Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Conversation

bnjmnt4n
Copy link
Contributor

@bnjmnt4n bnjmnt4n commented Sep 23, 2021

What kind of change does this PR introduce?

Feature.

What is the current behavior?

RPC function calls are made only using POST.

What is the new behavior?

Users can customize the HTTP request type to GET or HEAD. This allows for selecting the count of rows in a function call returning a table without selecting any data with the HEAD request type and count option.

Implementation Notes

@soedirgo
Copy link
Member

Thanks for the PR! Somehow I forgot to support HEAD for rpc.

For HEAD, I think it's better to follow how it's done for select instead:

select(
columns = '*',
{
head = false,
count = null,
}: {
head?: boolean
count?: null | 'exact' | 'planned' | 'estimated'
} = {}
): PostgrestFilterBuilder<T> {

Looking at the docs, it doesn't seem like there's anything GET does that POST can't do, and sending params as request body is cleaner (URL has length limit and all that), so supporting GET probably isn't necessary.

@bnjmnt4n
Copy link
Contributor Author

One case I could think of (although certainly niche) is that service workers are unable to cache POST requests.

@soedirgo
Copy link
Member

Hmm yeah, I don't have anything against it but maybe best to leave it out until there's a feature request for it.

@bnjmnt4n
Copy link
Contributor Author

@soedirgo updated! I guess it's good to avoid unnecessary complexity until it's really required, and this does have more consistency with select.

@soedirgo soedirgo merged commit a53f81b into supabase:master Sep 25, 2021
@bnjmnt4n
Copy link
Contributor Author

Should I send a corresponding PR to integrate this into supabase-js?

@github-actions
Copy link

🎉 This PR is included in version 0.34.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bnjmnt4n bnjmnt4n deleted the rpc-request-method branch September 27, 2021 11:22
@soedirgo
Copy link
Member

Yes please, that'd be rad 🙏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants