Closed ValentinVignal closed 2 years ago
Thanks. I withdrew that version from pub.dev. Unfortunately I don't have access to a laptop today, so I can't give more details at the moment.
If you want to help, I would greatly appreciate it if you could try passing the generated "possibleTypesMap" from the Schema.graphl.dart file to the cache constructor and see if this fixes that.
Tracked it down to a change in normalize 0.6.0. Possible workaround is to use normalize 0.5.x via dependency overrrides.
possible fix using ferry_cache from this branch PR: https://github.com/gql-dart/ferry/pull/380
and passing the generated possibleTypesMap
from the generated schema.gql.dart file to the Cache
constructor.
You also stumbled upon another bug in your repro: If the schema is very simple and contains no inputs, no enums and no unions, no schema.gql.dart file is created. This should almost never happen in production scenarios though so it's probably no big deal.
You can try it out in your repro by adding some dummy input like
input PokemonInput {
name: String!
}
to the schema.graphql file in your repro-project.
I assume you ran into this on a real-world project, I would be grateful if you could try the fix on this project.
TL;DR:
use ferry_cache from
ferry_cache:
git:
url: https://github.com/gql-dart/ferry.git
ref: fix/cache_possible_types_fix
path: packages/ferry_cache
and change the instantiation of your cache object to Cache(possibleTypes: possibleTypesMap, ....)
(with possibleTypesMap imported from your schema.gql.dart file) and see if the problem persists.
I confirm that using
ferry_cache:
git:
url: https://github.com/gql-dart/ferry.git
ref: fix/cache_possible_types_fix
path: packages/ferry_cache
and adding a
input PokemonInput {
name: String!
}
on the repo I provided fixes the issue, I will need some time to try it out on my real-world project.
@knaeckeKami The fix is working on our real-world app too ! 🎉
Great. Released ferry 0.11.0 (since the possibleTypesMap requirement for full cache compatibility is a breaking change)
As an update: it works on the minimal repo I provided in the issue 🎉 I still need to try it out on our real-app world
It is working on our real-app world ! 🎉 Thank you a lot for the support
When reading a query from the cache which contains a fragment on an interface, it crashes because the id is missing from the json and built_value cannot deserialize it.
You can checkout:
https://github.com/ValentinVignal/flutter_app_stable/tree/ferry/bug-cache
or run this code:
When I run
I get
GraphQL files
```graphql # schema.graphql interface PokemonInterface { id: ID! name: String! } type Pokemon implements PokemonInterface { id: ID! name: String! } type Query { pokemons: [Pokemon!]! } ``` ```graphql # pokemon_fragment.graphql fragment PokemonFragment on PokemonInterface { id name } ``` ```graphql # pokemon_query.grapql # import './pokemon_fragment.graphql' query Pokemons { pokemons { ... PokemonFragment } } ```