# Apollo useQuery fetch data cache ###### tags: `Apollo` `errorNote` `useQuery` `cache` > useQuery fetch data is different in network and console.log > network 跟 console.log 印出不一樣 :astonished: > 哎呀,原來是 cache 住拉 我發了 issue 呢,快來抗抗 >> [useQuery fetch data is different in network and console.log](https://github.com/apollographql/apollo-client/issues/8359) ### 最終解法是在 `InMemoryCache` > `typePolicies` 加上 data 的 key 值 MsgInvite ``` const createApolloClient = ({ onError }) => { return new ApolloClient({ link: from([authMiddleware, createErrorLink(onError), splitLink]), cache: new InMemoryCache({ typePolicies: { MsgInvite: { keyFields: ['inviteeUserIDs'] } } }) }); }; ``` 或是你遇到的是 refetch cache 的問題呢? [Apollo useQuery refetch cache](https://hackmd.io/@yellow/H1UlLGsju)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up