Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set RPC to send by GET with query params #438

Closed
digoburigo opened this issue Jun 20, 2023 · 5 comments · Fixed by #529
Closed

How to set RPC to send by GET with query params #438

digoburigo opened this issue Jun 20, 2023 · 5 comments · Fixed by #529
Labels
documentation Improvements or additions to documentation

Comments

@digoburigo
Copy link

digoburigo commented Jun 20, 2023

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}...

@digoburigo digoburigo added the documentation Improvements or additions to documentation label Jun 20, 2023
@steve-chavez
Copy link
Member

What's the use case for doing GET with postgrest-js? Right now it only does RPC through POST.

@digoburigo
Copy link
Author

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

@steve-chavez
Copy link
Member

@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} }.

@digoburigo
Copy link
Author

@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!

@markalexander
Copy link

markalexander commented Sep 25, 2023

@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.

@soedirgo soedirgo reopened this Mar 28, 2024
@soedirgo soedirgo linked a pull request Mar 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants