【发布时间】:2022-06-12 20:44:59
【问题描述】:
假设我有以下获取产品列表的查询。
query ProductList() {
products() {
name
price
stockQuantity
isAvailable @client # This is a local-only field
}
}
我还在内存缓存创建时为仅限本地字段添加了类型策略,并带有读取功能:
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
}
}
}
}
}
});
如何在isAvailable读取函数中获取父Product对象的stockQuantity字段?
【问题讨论】:
标签: javascript graphql apollo-client apollo-cache-inmemory