gql-dart / ferry

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

TypePolicy is broken Or there is no clear documentation about it. #597

Closed ebsangam closed 3 months ago

ebsangam commented 3 months ago

I am trying to merge paginated result into the cache but it very difficult to implement and eventually it does not work. I am facing following issue and don't know how to solve.

knaeckeKami commented 3 months ago

The repro does have non-public dependencies, I can't run it. It's also very big and has a lot of files and architecture. It also does not seem to actually use any type policies. Could you reproduce a more minimal example?

Or just show, with what data does the merge function get called, how do you merge them, and how does the exception get triggered?

ebsangam commented 3 months ago

Thank you for quick response. I will provide you minimal example.

ebsangam commented 3 months ago

I have pushed a new branch without local dependency. https://github.com/ebsangam/graphql_caching/tree/minimal-example This still has uses injectable/get_it for DI. I should run on you machine. Let me know if I need to remove injectable/get_it too.

knaeckeKami commented 3 months ago

What are the steps to reproduce the issue?

ebsangam commented 3 months ago

I have just updated the branch and removed all dependencies to third party packages that was not needed to reproduce the issue. https://github.com/ebsangam/graphql_caching/tree/minimal-example To reproduce:

ebsangam commented 3 months ago

Be sure to pull the latest changes.

ebsangam commented 3 months ago

@knaeckeKami also uncomment typePolicies in /ferry/client.dart. I missed to uncomment.

knaeckeKami commented 3 months ago

I can't seem to get it working. but I think you return a list of posts in your merge callback, when you should return a map that matches PostPage

ebsangam commented 3 months ago

Oh thanks. Solved. I am dumb to forget this when using dynamic types.

ebsangam commented 3 months ago

However we can make another ticket to make type policy type safe. It is too hard to work with dynamic types. What do you think?

knaeckeKami commented 3 months ago

you can create a ticket, but I don't see how fieldpolicies could be made typesafe.

ebsangam commented 3 months ago

Ok for now I am closing this issue. Thanks for your help.