tRPCttRPC
Powered by
seb1S
tRPC•8mo ago•
9 replies
seb1

How to abort a streaming mutation

I have a streaming mutation working, but I need to be able to abort it. I've seen this thread but that syntax doesn't appear to be valid for the React version.

If I do this:
foo.mutate(
  { exampleInputData: 'hello world' },
  { signal: abortController.signal },
)
foo.mutate(
  { exampleInputData: 'hello world' },
  { signal: abortController.signal },
)


then I get the type error that
'signal'
'signal'
does not exist on mutation options.

If I try the new tanstack-query client syntax (from this migration guide), well that also doesn't work because the property
mutationOptions
mutationOptions
doesn't exist in this call:

const mutation = useMutation(trpc.threads.example.mutationOptions());
const mutation = useMutation(trpc.threads.example.mutationOptions());


That migration guide doesn't specify how the
useTRPC
useTRPC
custom hook is meant to be implemented, so I suspect there's something I'm missing there?

So my main questions are:
1. Is it possible to abort a streaming mutation client-side with a react trpc client?
2. if yes, can this be done using the old syntax? or if we need to use the new syntax, what code for the
useTRPC
useTRPC
hook makes the types check out?

Thanks in advance!
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How to extract mutation type
MugetsuMMugetsu / ❓-help
2y ago
Unable to abort Suspense queries
phibr0Pphibr0 / ❓-help
2y ago