Closed sharmapukar217 closed 1 year ago
Are you saying that the first example works and the second doesn't? If so, this is how it is supposed to work and it was wrong initially, which has been fixed now. You don't pass the input to useMutation
, but instead when you call the .mutate
method. Refer to https://trpc.io/docs/useMutation for usage instructions. Does this resolve the issue?
If not, could you please add a comment with the error that typescript is throwing?
The first one doesn't work. The second one works but typescript shows error
I know the variables are passed to . mutate () function.. this might be the problem of svelte query because the first params of onMutate() seems to hold variables passed to . mutate function which is the not case. According to react query doc, the first param of onMutate is data
Hmmm, that's peculiar... Either way, there was a major update a few days ago where I restructured a bunch of stuff. Could you try updating to v2.0.0
and let me know if the issue is still present?
Sure I'll check it and inform you soon
v2 seems to have more errors. typescript shows trpc().useContext() is not present in procedure something like this.
v2 has had some breaking changes. Tje procedures are called create<procedure>
now to be more consistent with tanstack query. There was a note in the README of the previous version that this would be done.
Its createContext
now instead of useContext
.
Oh my bad. V2 is working fine 😊 closing the issue
Error: Property 'createInfiniteQuery' does not exist on type 'QueryProcedures<any, { users: SerializeObject<UndefinedToOptional<Omit<User, "password">>>[]; pageParams: SerializeObject<UndefinedToOptional<{ endCursor: any; startCursor: string; }>>; }, TRPCClientErrorLike<...>>'.
what does this mean? The data is showing but typescript is giving such error
Could you share your trpc router and how you called it in the component so that I can take a look?
when using trpc.procedure.useMutation({ onMutate() {}, onError() {}, ...rest }) trpc.procedure.useMutation(undefined, { onMutate() {}, onError() {}, ...rest }) seems to be working but then typescript shows error