Closed natecraft1 closed 5 years ago
I would highly discourage persisting raw GraphQL models / data. I'd recommend migrating to a custom JSON serialization format that doesn't rely on GraphQL field versioning to prevent this in the future. For now, as a workaround, you can request both deprecated and non-deprecated fields to avoid crashing.
@dbart01 Thanks, I took the serialization from the example project's CartController. If possible could you elaborate on how you might persist CartItems without GraphQL models. I guess my confusion is that properties within CartItem contain models which are Storefront models. Maybe it would suffice to just store the ids of the models and fetch them when possible? Anyways would like to know your thoughts, any direction helps.
The idea is to abstract GraphQL models behind your own version of CartItem
that knows how to serialize and deserialize from a JSON representation. Doing so will allow you to update the GraphQL schema, which may add or remove fields, without affecting the ability to read / write to and from your JSON representation. You can then add default values in your proprietary model for new / missing fields, etc. Hopefully this makes a little more sense.
Images now have a transformedSrc rather than a src property. We are getting a crash after updating the SDK because we have CartItems stored locally and when we try to deserialize them, their Image models don't match because they contain the old src property. This leads to a crash in GraphQL
What is the proper way to introduce new properties without crashing the app? Thanks!