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

160
Vistas
How do you test cache only queries in apollo?

I have a query like this:

  const { data } = useQuery(GET_STUFF, {
    fetchPolicy: "cache-only",
  })

This works fine in the code. In the tests data is undefined

but I've mocked it like so:

  {
    request: {
      query: GET_STUFF,
    },
    result: {
      data: {
        __a: {
          id: "12",
        },
      },
    },
  },

but when I change fetchPolicy to fetchPolicy: "network-only" it then comes through as the expected result.

The problem also is I can't also pass cache into <MockedProvider /> as I have queries on that page that also use network-only

How do I solve this or throw stuff automatically into the cache?

about 4 years ago · Juan Pablo Isaza
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