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

72
Vistas
Get parent object at field type policy

Let's say that I have the following query that fetches a list of products.

query ProductList() {
  products() {
    name
    price
    stockQuantity
    isAvailable @client # This is a local-only field
  }
}

Also I have added a type policy for a local-only field at the in-memory cache creation, with a read function:

const cache = new InMemoryCache({
  typePolicies: { // Type policy map
    Product: {
      fields: { // Field policy map for the Product type
        isAvailable: { // Field policy for the isAvailable field
          read(existing, context) { // The read function for the isAvailable field
            // Return value
          }
        }
      }
    }
  }
});

How can I get the stockQuantity field of the parent Product object at the isAvailable read function?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

const cache = new InMemoryCache({
  typePolicies: { // Type policy map
    Product: {
      fields: { // Field policy map for the Product type
        isAvailable: { // Field policy for the isAvailable field
          read(existing, {readField}) { // The read function for the isAvailable field
            const stockQuantity = readField("stockQuantity");
            return stockQuantity ? true : false;
          }
        }
      }
    }
  }
});
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