【发布时间】:2021-02-05 13:31:20
【问题描述】:
我有一个 Apollo 查询集,如下所示。
query {
speakers {
id
name
checkBoxField @client
}
}
我的字段策略设置如下:
export const genericBoolean = cache.makeVar(false);
typePolicies: {
Speaker: {
fields: {
checkBoxField: {
read(checkBoxField = false) {
return genericBoolean === true ? "true" : "false";
...
我的页面上有一个按钮,我使用 useQuery 定义并且该按钮执行代码:
onClick : genericBoolean(true)
当我转储 (JSON.stringify) 从 useQuery 返回的数据时,checkBoxField 会按预期对所有行更改为 true,但在我的 Apollo 缓存中(从 chrome 扩展中可以看出),没有为 checkBoxField 存储字段。我想要那个,这样我就可以遍历我的缓存并为每一行获取值。
【问题讨论】:
标签: graphql apollo react-apollo