gql-dart / ferry

Stream-based strongly typed GraphQL client for Dart
https://ferrygraphql.com/
MIT License
593 stars 113 forks source link

writeQuery does not emit new event for request stream after modifying TypePolicy in cache #562

Closed LiLatee closed 7 months ago

LiLatee commented 7 months ago

Hi! I've spent a few hours trying to investigate it and I don't know what's the problem. I have such a function for clearing some list in the cache. It works fine. Stream emits new data with the cleared list of items.

image

But after adding such TypePolicy to the cache then it does not work.

image image

I mean that the cache is modified properly, but the stream does not emit new data in order to refresh page content. In both cases event is printed in the first screenshot at line 137.

Why is that happening? 🤔

knaeckeKami commented 7 months ago

Good question!

I don't know yet, but I see something wrong:If the RootQueryType is your root query type, you should add this to your type policy.

This might be it.

See https://ferrygraphql.com/docs/cache-configuration#overriding-root-operation-types-uncommon

LiLatee commented 7 months ago

Oh my God, you are right! I had that before, but I don't know why I removed it... After indicating that RootQueryType is my queryType it works fine ❤️

image