Closed digoburigo closed 3 months ago
What's the use case for doing GET with postgrest-js
? Right now it only does RPC through POST.
My use case is a postgrest connected to a replica database for read only, so POST requests don't work. Error that occurs is referenced in this StackOverflow issue, for example
@digoburigo If you mark your functions with STABLE
or IMMUTABLE
:
CREATE FUNCTION --..
$$;
LANGUAGE SQL STABLE;
Then PostgREST will run it under a READ ONLY
access mode. That should avoid that error.
For more details, see https://postgrest.org/en/stable/references/transactions.html#access-mode.
That being said I think we could add a parameter to rpc
for using a GET. Maybe on options
({options: { get: true} }
.
@steve-chavez oh nice, thanks for the info. Must have looked better in postgrest docs.
For the options in the postgrest-js
would be nice to have.
Feel free to close this issue then!
@soedirgo thanks—do you know which release this will be in, or even just the PR/commit so I can track it through?
Edit: or maybe I misunderstood the conversation above and we didn't resolve to add the option?
Another use-case: we use RPC for dashboard widget data functions that take abstracted/common params (date range, granularity, etc.). Our CDN can cache this data nicely at the edge for GET
requests, but not for POST
. Most CDNs have a similar dichotomy, I believe.
Improve documentation
Link
https://supabase.github.io/postgrest-js/v2/classes/PostgrestClient.html#rpc
How to make a RPC call with GET and query params
Describe the problem
Don't have an example or how to do it
Example:
GET https://postgrest-url.domain/rpc/{function}?{param}={value}...