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

我正在使用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;
  }
iCMS 回答:阿波罗升压器第二次不工作(缓存的数据)

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1531341.html

大家都在问