Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
How to check that ApolloError is caused by client internet connection?

ApolloError has networkError prop, but it is set when server responds with 4** or 5** status code.

And how to check that the problem is caused by bad internet connection?

try {
   apolloClient.query(someQuery)
} catch (error) {
  if (isInternetConnectionError(error)) { // how to check this?
    Alert.alert('Please check your internet connection!')
  } else {
    logException(error);
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Seems that there is not good way to get that (nice work Apollo), but this is the exact error state that comes when there is no internet:

export const isNetworkError = (error: unknown) => {
  return (
    error instanceof ApolloError &&
    error.message === 'Network request failed' &&
    error.graphQLErrors.length === 0 &&
    error.clientErrors.length === 0 &&
    error.networkError &&
    Object.keys(error.networkError).length === 0
  );
};

Actual for "@apollo/client": "3.4.7"

Or here is much shorter version that should work:

export const isNetworkError = (error: unknown) => {
  return (
    error instanceof ApolloError &&
    error.message === 'Network request failed'
  );
};
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda