Mutations with no return value stall forever
See original GitHub issueWhen a resolve
callback’s return type is either:
Promise<void>
Promise<null>
Promise<undefined
tRPC doesn’t ever close the response stream, thus, stalling the client indefinitely.
The following code doesn’t work:
trpc.router<Context>()
.mutation("update", {
input: z.object({ id: z.string() }),
resolve: async ({ ctx, input }): Promise<void> => {
await updateSection(input);
// `return undefined` or `return null` wouldn’t solve the case
},
});
But the following return value change does the trick:
trpc.router<Context>()
.mutation("update", {
input: z.object({ id: z.string() }),
resolve: async ({ ctx, input }): Promise<{ [key: string]: never }> => {
await updateSection(input);
return {};
},
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Is it possible to not return any data when using a GraphQL ...
I have several GraphQL queries and mutations, now I'm trying to implement a delete mutation without returning any data: type Mutation{ ...
Read more >Mutations in Apollo Client - Apollo GraphQL Docs
To refetch a query from onQueryUpdated , call return observableQuery.refetch() , as shown above. Otherwise, no return value is required. If a refetched...
Read more >Guide to Genetics - Space Station 13 Wiki
Through the Gene Booth, you can share Mutations without having to stray from the console. When you access an occupant's Mutations or Stored ......
Read more >how to write a mutation schema which returns null? · Issue #277
I am trying to write a schema with a single mutation, which should return null. Problem is when I try to do that,...
Read more >Best practices for GraphQL mutations - Fauna
GraphQL mutations are used to modify data in your API. ... Return type specifies that this mutation must always have a return value....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@KATT This is not related to #512 , but might be an indication for the same problem. I think we should generally add tests for these non-defined cases, so we can catch bugs like this or like #512. (We need tests for undefined/null/{}/void input and output.) I just saw, you’ve already added a test now. If you need help, I can add some more tests regarding that later today.
@simonedelmann happy if you can review the PR ❤️ and challenge the way I did it