[英]How to invalidate cache in apollo?
有誰知道如何在apollo
執行緩存無效化?
我在解析器中設置緩存提示:
export default (root, args, { userId }, { cacheControl }) => {
cacheControl.setCacheHint({ maxAge: 60 });
return userId && Meteor.users.findOne(userId);
};
但是,如果發生變化並且maxAge
足夠大,則不會反映出變化。
我現在正在考慮在突變中調用cacheControl.setCacheHint({ maxAge: 0 })
,還有其他方法嗎?
您可以檢查以下內容: https : //github.com/lucasconstantino/apollo-cache-invalidation#readme
您可以使用功能匹配
const randomKeyMatch = key => Math.random() >= 0.5
const update = invalidateFields(() => [
[randomKeyMatch, 'happy']
])
client.mutate({ mutation, update })
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.