-
I have recently an issue regarding an infinite loading due to the app did not get any response for the backend so the spinner never ends. My question is, despite the issue is in the backend, does anyone know if there is an option for adding a timeout for queries/mutations in case backend does not respond due to an issue? Many thanks in advance! |
Beta Was this translation helpful? Give feedback.
Answered by
enisdenjo
Mar 19, 2023
Replies: 1 comment 9 replies
-
You can create a timeout yourself. Roughly: import { createClient } from 'graphql-ws';
const client = createClient({
url: 'ws://localhost:4000/graphql',
});
let timeout;
const dispose = client.subscribe(
{
query: '{ slowQuery }',
},
{
next: (value) => {
// value received, clear timeout
clearTimeout(timeout);
},
error: (err) => {},
complete: () => {},
},
);
// remove subscription after a timeout of 3 seconds
timeout = setTimeout(dispose, 3000); |
Beta Was this translation helpful? Give feedback.
9 replies
Answer selected by
acuevas91
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can create a timeout yourself. Roughly: