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

How to return partial data from cache? #1389

Open
jaromirkrotky opened this issue Nov 9, 2023 · 0 comments
Open

How to return partial data from cache? #1389

jaromirkrotky opened this issue Nov 9, 2023 · 0 comments

Comments

@jaromirkrotky
Copy link

Hello,

I would like to ask you for an advice. I have an application that uses GraphQL with Hive cache. So active users already have in storage object (of course they have a lot of another objects there also):
{id: 654c05b10fb2816b81002592, email: null, phone: null, createdAt: 2023-11-08 23:03:29.678, updatedAt: 2023-11-08 23:03:29.678, deletedAt: null, __typename: User}

Now I add new nullable attribute "allowDelete" to schema and regenerate objects with graphql_codegen. For new installation of the app everything works correctly and data look like this:
{id: 654c05b10fb2816b81002592, email: null, phone: null, createdAt: 2023-11-08 23:03:29.678, updatedAt: 2023-11-08 23:03:29.678, deletedAt: null, allowDelete: true, __typename: User}

Problem is with the old users who updated previous version of the app, because readFragment$User returns null. I checked that the old user json (the first one) is still in Hive and problem is that it is not loaded because of PartialDataException. It is checking all keys and "allowDelete" is not there.

I investigate that returnPartialData is strictly set to false and should be used just for testing (setting to true will solve it, but I understand that it may cause another problems). So what is the correct way to solve this situation? I need to be able to load older data to start the app and load new data. Create another fragment (with new attribute) do not seems ideal to me, because it means to change a lot of parts of the app (the update is not just about one attribute of one object but a lot of new attributes in a lot of object - all new attributes are nullable).

Thank you, Jaromir

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

1 participant