这个问题可能是由于graphql缓存未正常清除所致。您可以尝试在resetStore之前手动清除缓存。以下是可能的解决方案:
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloClient } from 'apollo-client';
const cache = new InMemoryCache();
const client = new ApolloClient({
cache,
...
});
// 在调用resetStore之前手动清除缓存
cache.reset();
client.resetStore();
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloClient } from 'apollo-client';
const cache = new InMemoryCache();
const client = new ApolloClient({
cache,
...
});
const resetStore = client.resetStore.bind(client);
// 添加缓存清除回调函数
client.resetStore = async () => {
cache.reset();
await resetStore();
};
// 调用resetStore
client.resetStore();
这些解决方案应该可以解决您在调用resetStore时出现GraphQL/Mongoose查询错误的问题。