调用Apollo-client的resetStore()
函数来清除缓存,然后再发出正确参数的请求,例如:
import { ApolloClient, InMemoryCache } from "@apollo/client";
const client = new ApolloClient({
uri: "https://graphql.example.com",
cache: new InMemoryCache(),
});
// ...
// 调用 resetStore() 函数清除缓存
client.resetStore().then(() =>
// 发出正确参数的查询请求
client.query({
query: GET_USERS,
variables: { limit: 100 },
})
);