Imagine you have a query that retrieves a list of products like the one below.
query ProductList() {
products() {
name
price
stockQuantity
isAvailable @client # This field exists only locally
}
}
In addition, you've set up a type policy for the local-only field in the in-memory cache creation, including a read function:
const cache = new InMemoryCache({
typePolicies: { // Map of type policies
Product: {
fields: { // Map of field policies for the Product type
isAvailable: { // Field policy for the isAvailable field
read(existing, context) { // Read function for the isAvailable field
// Need to access the stockQuantity field of the parent Product object here
}
}
}
}
}
});
How can you access the stockQuantity
field of the parent Product object within the isAvailable
read function?