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

Remove local cache mutation type case setter #3443

Closed
calvincestari opened this issue Sep 17, 2024 · 0 comments · Fixed by apollographql/apollo-ios-dev#485
Closed

Remove local cache mutation type case setter #3443

calvincestari opened this issue Sep 17, 2024 · 0 comments · Fixed by apollographql/apollo-ios-dev#485
Assignees
Labels
bug Generally incorrect behavior codegen Issues related to or arising from code generation

Comments

@calvincestari
Copy link
Member

calvincestari commented Sep 17, 2024

Local cache mutations are mutable and the properties have both get and set accessors generated. This is fine for scalar and entity type properties but causes a problem with type conditions.

The problem is that the setter for the type condition is only changing the internal Dictionary (_data) value but none of the metadata (_fulfilledFragments and _deferredFragments) needed during execution. The result is that if a selection set is instantiated and then the type condition setter overwrites the underlying data, committing that data to the cache often results in errors when execution is performed.

Is this a breaking change?
The correct way to initialize a selection set through a type condition is to use the asRootEntityType property which correctly sets the underlying DataDict which in turn handles the internal Dictionary storage and the associated execution metadata. This exists already and is documented.

The existing type case setters are causing unintended runtime errors and were not intended to be used this way therefore I do not think removing them should be considered a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior codegen Issues related to or arising from code generation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant