微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

阿波罗升压器第二次不工作缓存的数据

如何解决阿波罗升压器第二次不工作缓存的数据

我正在使用apollo-boost进行缓存。第一次看到网络呼叫,第二次返回页面时没有网络呼叫,但是缓存的数据是前一页的混合。我有主页和关于页面。我在主页中,转到“关于”页面,然后返回主页,我也从“关于”页面看到数据。
import ApolloClient from 'apollo-boost';
const client = new ApolloClient({ uri: 'http://localhost:4000' });
ReactDOM.render(
        <ApolloProvider client={client}>
          <Container  />
        </ApolloProvider>,document.getElementById('root')
      );

import { ApolloClient,InMemoryCache,ApolloLink,IntrospectionFragmentMatcher } from 'apollo-boost';
import { createPersistedQueryLink } from "apollo-link-persisted-queries";
import introspectionQueryResultData from '../../src/fragmentTypes.json';

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData
});
const cache = new InMemoryCache({
  fragmentMatcher,});
const APIURL = sessionStorage.getItem('REACT_APP_API_URL');
const httpLink = createPersistedQueryLink().concat(createHttpLink({ uri: APIURL }));
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;
  }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。