supabase-js icon indicating copy to clipboard operation
supabase-js copied to clipboard

Ability to add arguments to supabase custom fetch documented

Open mjsisley opened this issue 2 years ago • 4 comments

Improve documentation

It is possible to set a custom fetch that supabase client will use. But how are arguments passed to this custom fetch with the query builder api?

Link

https://supabase.com/docs/reference/javascript/select How to pass arguments to a custom fetch?

Describe the problem

It is unclear if it is possible or how to pass arguments to a custom fetch. Clippy did have some ideas; but these did not work when tried.

Describe the improvement

Show an example of the query building api using custom fetch and additional arguments being past to it.

Additional context

For my specific use case - is it possible to use the nextjs 13 fetch and pass arguments to set per query caching instead of being limited to using segment level caching as shown in the documentation currently export const revalidate = 60.

It is unclear if it is possible or how to accomplish passing arguments to the specified custom fetch

mjsisley avatar Mar 18 '23 22:03 mjsisley

Its fully possible, see https://github.com/supabase/supabase-js/issues/725#issuecomment-1578811299

sannajammeh avatar Jul 03 '23 18:07 sannajammeh

@sannajammeh I tried this a few days ago, and typescript threw all sorts of errors?

AarooneyFarr avatar Oct 30 '23 20:10 AarooneyFarr

@sannajammeh I tried this a few days ago, and typescript threw all sorts of errors?

Most likely you have conflicting environment types from the types that supabase expects from fetch. This is common in almost all frameworks where fetch is polyfilled with node-fetch or similar.

I would simply place a // @ts-expect-error comment above the line as it's most likely a type conflict between global type of RequestInit and Supabase's internal type of RequestInit. Without seeing your error I won't know for sure though.

sannajammeh avatar Oct 30 '23 22:10 sannajammeh

@sannajammeh What if I want to add a tag to a particular data request that I can revalidate later with revalidateTag ?

NidalCatalyst avatar Jan 01 '24 10:01 NidalCatalyst