Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LazyCacheMap limits #629

Closed
SwannLV opened this issue May 8, 2020 · 7 comments
Closed

LazyCacheMap limits #629

SwannLV opened this issue May 8, 2020 · 7 comments

Comments

@SwannLV
Copy link

SwannLV commented May 8, 2020

Hello!

Any short term plan to change LazyCacheMap to something that would look if all the fields of the query are in the cache before returning a value?
I am really struggling without it..
(I am using typename/id normalization)

Thanks a lot!

@micimize
Copy link
Collaborator

micimize commented May 8, 2020

so, you're essentially attempting to deserialize an operation from the cache, but one of the referenced entities does not have all the expected fields, and thus is creating an issue?

I'm not sure where this would happen, except for situations where the cache is broken.

@SwannLV
Copy link
Author

SwannLV commented May 8, 2020

If I am not mistaken, simply by calling a first request with a field abc having subField1 and subField2.
Then a second request with the same field abc having subField3 and subField4.

The result of the second request for me is subFields 1 & 2, but should have been 3 & 4.

I am using NormalizedInMemoryCache with dataIdFromObject: typenameDataIdFromObject.

Thanks!

@micimize
Copy link
Collaborator

micimize commented May 8, 2020

@SwannLV ohh I see. Yes that that is definitely an issue. We can't really solve it without #471, which will be part of v4 #608, which is now my priority so it could be called a short-term plan

Closing as sub-issue of #471

@SwannLV
Copy link
Author

SwannLV commented May 8, 2020

Good news! Can't wait for that 🙂

@SwannLV
Copy link
Author

SwannLV commented May 9, 2020

Hey @micimize ! I am sorry but I have found what caused this problem! In fact I don't have any problem now! But there might be a very little bug during the merge of old cache and new cache value.

query queryA {
   me {
     abc {
       id
         __typename
           user { # cache key: user/2
             id
             __typename
             fieldA
             fieldB
          }
       }
   }
}


query queryB {
   me {
       id
       __typename # => user
       abc {
         id
         __typename
         user { # resolves the partial user/2 from `queryA` which is incorrect
           id
           __typename # => user
           fieldC
           fieldD
        }
     }
   }
}

But if I remove me.__typename, the cache works perfectly well!

Working queryB:

query queryB {
   me {
      id # it works if __typename is removed !
      abc {
        id
        __typename
        user {
          id
          __typename
          fieldC
          fieldD
        }
      }
   }
}

@micimize
Copy link
Collaborator

micimize commented May 9, 2020

@SwannLV what you're doing there is basically a workaround to disable normalization, because it won't flatten result unless there's a __typename + id

@SwannLV
Copy link
Author

SwannLV commented May 9, 2020

Indeed, but if i remove normalization on 'me', normalized cache on 'user' works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants