Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apollo server timeout message

I'm using apollo server and graphql and it's necessary to set a timeout so I use this with express:

   const server = app.listen({ port: 4000 }, () =>
       console.log( `The server is running in http://localhost:4000${server.graphqlPath}`));

   server.setTimeout(60000);

This works to set a timeout, but I receive the following message in my Apollo Server Playground:

{
  "error": "Failed to fetch. Please check your connection"
}

But I think is not ok to send only that text, so can I edit that message or add some properties to the error that I receive?, It take me a while to search in some places with no success.

like image 643
andresloal Avatar asked Apr 15 '26 21:04

andresloal


1 Answers

This error message is not sent by server-side. It's a client-side error.

Here is the source code of this error for graphql playground.

export function formatError(error, fetchingSchema: boolean = false) {
  const message = extractMessage(error)
  if (message === 'Failed to fetch') {
    const schemaMessage = fetchingSchema ? ' schema' : ''
    return { error: `${message}${schemaMessage}. Please check your connection` }
  }

  try {
    const ee = JSON.parse(message)
    return ee
  } catch (e) {
    //
  }

  return { error: message }
}
like image 86
slideshowp2 Avatar answered Apr 18 '26 10:04

slideshowp2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!