Graphql Apollo boost第二次不工作(缓存数据)

Graphql Apollo boost第二次不工作(缓存数据),graphql,react-apollo,apollo-client,apollo-cache-inmemory,apollo-boost,Graphql,React Apollo,Apollo Client,Apollo Cache Inmemory,Apollo Boost,我正在使用阿波罗助推。第一次看到网络调用,第二次返回页面时没有网络调用,但缓存的数据是前一页的混合数据。我有主页和关于页面。我在主页上,我转到关于页面,然后回到主页,我也看到关于页面的数据 import ApolloClient from 'apollo-boost'; const client = new ApolloClient({ uri: 'http://localhost:4000' }); ReactDOM.render( <ApolloProvider cli

我正在使用阿波罗助推。第一次看到网络调用,第二次返回页面时没有网络调用,但缓存的数据是前一页的混合数据。我有主页和关于页面。我在主页上,我转到关于页面,然后回到主页,我也看到关于页面的数据

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;
  }
从“apollo boost”导入apollo客户端;
const client=新客户端({uri:'http://localhost:4000' });
ReactDOM.render(
,
document.getElementById('root'))
);
从“apollo boost”导入{apollo客户端、InMemoryCache、ApolloLink、IntrospectionFragmentMatcher};
从“apollo链接持久化查询”导入{createPersistedQueryLink};
从“../../src/fragmentTypes.json”导入内省QueryResultData;
const fragmentMatcher=新的内省fragmentMatcher({
自省查询结果数据
});
常量缓存=新的InMemoryCache({
碎片匹配器,
});
const apirl=sessionStorage.getItem('REACT\u APP\u API\u URL');
const httpLink=createPersistedQueryLink().concat(createHttpLink({uri:APIURL}));
const客户端=新客户端({
link:authLink.concat(httpLink),//用httpLink链接它
隐藏物
});
const data=wait this.composequence(查询,参数);
异步复合序列(查询:any,参数:any){
const{data,errors}=wait client.query({
查询
变量:params
})
if(errors)返回此.notifyError();
如果(数据)返回数据;
}