apollo-boost如何进行查询的选择性缓存

问题描述

我想在阿波罗缓存中仅缓存少量查询。下面是我的代码,它将缓存所有查询。但是我只想缓存一些查询,其他查询不应该缓存。我该怎么办?

const client = new ApolloClient({
  link: authLink.concat(httpLink),// Chain it with the HttpLink
  cache
});

const data = await this.composeQuery(query,params);
async composeQuery(query: any,params: any) {
    const { data,errors } = await client.query({
      query,variables: params
    })
    if (errors) return this.notifyError();

    if (data) return data;
  }

如果我调用下面的方法,我会将不同的查询传递给composeQuery方法。仅某些查询必须被缓存。 const data = await this.composeQuery(query,params);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)