我想在阿波罗缓存中仅缓存少量查询。下面是我的代码,它将缓存所有查询。但是我只想缓存一些查询,其他查询不应该缓存。我该怎么办?
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);