ApolloClient timeout best option
<p>I came up with this way of doing network operations with <code>ApolloClient</code> but the problem is that the code looks very ugly and difficult to read, considering I have to write dozens of queries like this, it becomes tiresome and unmaintainable.</p>

<p>I haven't found anything in the Apollo docs or the actual code to configure the timeout.</p>

<pre><code>let query = gql`
  query ... {
}`;
let x = 0;
let timer = setTimeout(() =&gt; {
  if (x === 0) {
    console.log('error');
  }
  x = 1;
}, 3000);
ApolloClient.query({ query }).then(({data}) =&gt; {
  clearTimeout(timer);
  if (x === 0) {
    if (data.result) {
      console.log(data.result)
    } else {
      console.log('error');
    }
  }
}).catch((error) =&gt; {
  clearTimeout(timer);
  console.log('error')
});
</code></pre>

<p>Is there a better way of achieving the same result with less and simpler code?</p>