Closed zaquas77 closed 3 years ago
I have investigate a little more and I found a gap in configuration of my "useQuery" hook. If I add the property "returnPartialData" setting to true on option "userQuery", it seem works.
https://codesandbox.io/s/silly-hill-6b0mc
Is it correct use of that option? However if I try the same thing with apollo client 2.6 it continues failing. Have some idea?
thanks
I think your Query was getting in your way. They dislike anonymous queries in Apollo Client (those without a query name such as query MyQuery{...}
). They might be forcing them in beta as I thinking the names are used for query watches. Also I am not sure that you need @client(always: true)
and I think children of a @client directive automatically get the client directive attached.
working sandbox: https://codesandbox.io/s/vibrant-heyrovsky-eph49
const EXCHANGE_RATES = gql`
query GetRates {
isLoggedIn @client
user @client {
email
}
rates(currency: "USD") {
currency
rate
}
}
`;
My first comment was probably off topic. I saw what your real issue was with deleting and the cache not updating. There was a couple small issues.
cache.writeQuery
=> client.writeQuery
you were using client.mutate, while I dont think this was causing issues I think its probably bad practice and you should use the useMutation
hook.
The biggest problem was that you were sending in an empty object rather than null to reset the object. So when you say writeQuery with data only being { typename: 'User' } it is not actually writing anything because you are only telling it to write the `typenamefield. The sandbox I made sets
User: null` you could also pass in { __typename: 'User', email: null } Then the cache knows to overwrite that field.
Hi Kenny! You are right... I wrote the code after many hours of headache and fighting with apollo... So for now Apollo vs Stefano = 1 vs 0 :D Thanks for your explanation!
Answered by https://github.com/apollographql/apollo-client/issues/6068#issuecomment-604420865 - thanks!
Intended outcome: I want to clear partial of my localdata in cache:
For example
The cache have this data:
But If I update with
Actual outcome: The cache continues having the same data:
How to reproduce the issue: https://codesandbox.io/s/zealous-dan-63hbj
Versions System: OS: macOS 10.15.3 Binaries: Node: 12.13.0 - /usr/local/bin/node npm: 6.13.0 - /usr/local/bin/npm Browsers: Chrome: 80.0.3987.149 Firefox: 74.0 Safari: 13.0.5 npmPackages: @apollo/client: ^3.0.0-beta.41 => 3.0.0-beta.41