I am struggling to figure out how to get a (single row returning) Supabase function to run within a custom action.
During debugging, and for simplicity here, I've dialed back the test considerably to hone in on just the issue at hand.
I have a working (tested in Supabase SQL query window) Supabase function. For the time being, it's just a simple query that returns a single row from one of my tables. Ultimately there will be a bunch of logic that goes into this function to get to the single row returned. This is why I need a Supabase function vs just using the built in backend Supabase "query a table or view" functionality.
My Custom Action compiles successfully and basically looks like this:
Future<UsersRow> testCustomAction(String userId) async {
print('starting testCustomAction');
print(userId);
final client = SupaFlow.client;
final response =
await client.rpc('getUserDetail', params: {'userId': userId});
if (response.error != null) {
throw Exception('Failed to call stored procedure: ${response.error}');
} else {
// Assuming your stored procedure returns a single row
print(response);
return response.data as UsersRow;
}
}
I have this wired this to a Page Load action, and am using Authenticated User as the input parameter.
The custom Action gets called. I see the first two prints in the browser inspector window, and the authenticated userId is displaying correctly here. But then I get the following error that I have not been able to find a way past:
"PostgrestException(message: Could not find the function public.testCustomAction(userId) in the schema cache, code: PGRST202, details: Searched for the function public.testCustomAction with parameter userId or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache., hint: Perhaps you meant to call the function public.testCustomAction(userid))"
I haven't wired any of the response data to anything at this point (except for specifying an Action Return Variable in the page load action).
From everything I've researched, I've seen a couple limited examples, but nothing that has helped get me past this issue. I'm hoping there's someone out there who has successfully done what I am trying to do, or knows more than I do about this (which is likely most people ;)) and is seeing something I'm not.
Thanks in advance!