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

Trigger accepts only strings #229

Closed
boris-arkenaar opened this issue Jul 4, 2023 · 10 comments · Fixed by #230 or #232
Closed

Trigger accepts only strings #229

boris-arkenaar opened this issue Jul 4, 2023 · 10 comments · Fixed by #230 or #232
Labels
bug Something isn't working

Comments

@boris-arkenaar
Copy link

Describe the bug

With @supabase-cache-helpers/[email protected].

The trigger function coming from useUpsertMutation and useDeleteMutation seems to accept only a string as its first argument.

TypeScript gives me the following error:

No overload matches this call.
  Overload 1 of 3, '(extraArgument: string, options?: SWRMutationConfiguration<unknown[] | null, PostgrestError, Record<string, unknown>[], string, unknown[] | null> | undefined): Promise<...>', gave the following error.
    Argument of type '{ [x: string]: unknown; }' is not assignable to parameter of type 'string'.
  Overload 2 of 3, '(extraArgument: string, options?: (SWRMutationConfiguration<unknown[] | null, PostgrestError, Record<string, unknown>[], string, unknown[] | null> & { ...; }) | undefined): Promise<...>', gave the following error.
    Argument of type '{ [x: string]: unknown; }' is not assignable to parameter of type 'string'.
  Overload 3 of 3, '(extraArgument: string, options?: (SWRMutationConfiguration<unknown[] | null, PostgrestError, Record<string, unknown>[], string, unknown[] | null> & { ...; }) | undefined): Promise<...>', gave the following error.
    Argument of type '{ [x: string]: unknown; }' is not assignable to parameter of type 'string'.

Expected behavior
Expected to be able to supply an argument to the trigger function of type Record<string, unknown>[].

Additional context
Using the latest versions of all dependencies. Version 1.0.19 of @supabase-cache-helpers/postgrest-swr.

@boris-arkenaar boris-arkenaar added the bug Something isn't working label Jul 4, 2023
@psteinroe
Copy link
Owner

thanks for opening the issue. what supabase-js versions are you using?

@boris-arkenaar
Copy link
Author

Thanks for the quick response @psteinroe

The dependencies I've installed:

    "swr": "2.2.0",
    "@supabase/supabase-js": "2.26.0",
    "@supabase/postgrest-js": "1.7.1",
    "@supabase-cache-helpers/postgrest-swr": "1.0.19",

@psteinroe
Copy link
Owner

psteinroe commented Jul 4, 2023

Thanks for the quick response @psteinroe

The dependencies I've installed:

    "swr": "2.2.0",
    "@supabase/supabase-js": "2.26.0",
    "@supabase/postgrest-js": "1.7.1",
    "@supabase-cache-helpers/postgrest-swr": "1.0.19",

can you by any chance provide a repro? I am using the exact same versions, and do not have this type error. The swr example in this repo is also using the same versions, and the type error is not thrown.

@boris-arkenaar
Copy link
Author

At the moment I cannot reproduce the error anymore. I just moved from npm to pnpm and the type error is gone. Not saying npm was the problem, I have no idea what caused it. Happy that it works now. In case it comes back I'll try to make a repro. Sorry for the disturbance and thanks for the support!

@boris-arkenaar
Copy link
Author

No, still got it unfortunately. I'll try and make a repro.

@psteinroe
Copy link
Owner

I think I can replicate, will take a look asap.

@psteinroe
Copy link
Owner

yep, messed up the types. Will publish a fix tomorrow.

@psteinroe
Copy link
Owner

psteinroe commented Jul 5, 2023

still not fixed. investigating further...

@psteinroe psteinroe reopened this Jul 5, 2023
@psteinroe
Copy link
Owner

the culprit is actually an update to swr: vercel/swr#2669. publishing a fix soon.

@boris-arkenaar
Copy link
Author

Amazing you're able to replicate. I tried to replicate in a new repo, but didn't manage to get the error.
Let me try the fix you made. Thanks for picking this up so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants