svelte: mutate in a try catch
See original GitHub issueUsing @urql/svelte
I cannot use this simple code:
mutate({
query: DELETE_TODO,
variables: { id: todoID }
})
The mutation doesn’t start at all.
It just works like this:
mutate({
query: DELETE_TODO,
variables: { id: todoID }
}).then()
or like this:
async function callMutation() {
await mutate({
query: DELETE_TODO,
variables: { id: todoID }
})
}
but I wanna use the first one in a try {} catch {}
.
Is it possible?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
svelte: mutate in a try catch #756 - urql-graphql/urql - GitHub
The mutation doesn't start at all. I'll take a look at that, that seems unusual;. but I wanna use the first one in...
Read more >Mutations | Svelte Relay - GitHub Pages
If an error occurs in the mutation, the promise will be rejected with the error. You can use try/catch to handle these errors....
Read more >Apollo Mutation | Svelte Apollo GraphQL Tutorial - Hasura
We will use the mutation from Svelte Apollo in Svelte app as an example to insert new data and update cache locally using...
Read more >Dynamic behavior in Svelte: working with variables and props
To prove it, go to that array, and try changing some of the to-do object's completed property values, and even add a new...
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 Free
Top 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
The issue of lazy promises has been fixed; as per the global error exchange, I suppose if you already have one there isn’t much special to consider here? I’ll close for now but I think you had another thread going on Spectrum about this, right? 😃 https://github.com/FormidableLabs/urql/pull/758
The lazy promise was a mistake based on some assumptions so that shouldn’t be hard for us to fix (meanwhile you can just use async-await or call
then
as you discovered.Are you putting your error codes in extensions? If so you can identify your errors using
res.error.graphQLErrors.some(x => x.extensions.code === A_CODE)
where you defineextensions.code
or some other property