full-greenF
Refine2y ago
3 replies
full-green

Call Supabase RPC functions with useTable hook

Hi there,

Thanks in advance for reading.

I've been struggling to find an answer to this. I have a Postgres function in Supabase that performs a very specific (and kinda complicated) query, with quite a lot of filters, conditions and even geolocation checks. It would be very very handy if I was able to call that RPC function within the useTable hook to get it integrated through the Supabase Data Provider, but I can't to find any examples or tips on how to do that.

Searching here in the conversations I found that the suggested way is to not actually use the hook, but to call supabaseClient.rpc(...) directly. The thing is, would I have to code my own hook to get it working just as useTable does? Doesn't it ruin the advantages of using Refine at all? Is there a way to safely extend the Supabase Data Provider so I can add a method to call RPC functions, or wrap the existing methods?

I have checked the Supabase Data Provider code and found out that it is hardcoded to use the select method, thus making it impossible (AFAIK) to call RPC functions. Since I rely heavily on using Postgres Functions for many operations across the app, this is quite important for my project.

I am kinda new to Refine, so I might be missing something here. Any help is really appreciated.
Was this page helpful?