-
Notifications
You must be signed in to change notification settings - Fork 69
Support generating Encodable types #728
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
base: main
Are you sure you want to change the base?
Conversation
👷 Deploy request for apollo-ios-docc pending review.Visit the deploys page to approve it
|
In addition to feedback about the goal of this change, and its implementation, I was curious if there already exist:
|
Thanks so much for this PR @gsabran. We've talked about this feature in the past and had decided not to implement it. But it's been requested a number of times, and with a working implementation already proved out, I think it deserves re-consideration. The team will discuss this and get back to you! |
Thank you. Yes I remember reading something about why it was rejected in the past (but I could not find a pointer for this PR). My recollection was that this was because Apollo's normalized cache is the recommended way to do storage, and that when using it there is no need to manage serialization. I'm working on a project where the normalized cache is not scaling well and I would prefer to have the ability to do this myself. I'm not entirely sure this implementation works on all cases (would love some feedback on that or how to better test), but one nice aspect is that it required very few changes to the generated code as we get |
The team spoke about this today. We do want to accept an implementation of this, but there are both some things we think could be simplified. We could simplify the implementation by just making My big concern on the other hand, is that if we ship this, people are going to start asking for a As you identified, the correct way to do that would be by running the However I can't figure out how to overcome the issue of the input variables. When working with any operations that have The created If we were to include the values of the If what you want is just a |
Thanks, all those points make sense. I'll defer to you and the team on what you think are the best trade offs here. Maybe worth noting: it is possible to pass some configuration flag through the encoder's I was made aware that the implementation in this PR has issues and needs more work. I was wondering if within your tests you have something like
|
Support generating
Encodable
types:DataDict
conform toEncodable
Encodable
(there is no code to generate other than adding the protocol conformance) since the implementation is provided by an extension.Motivation
In some contexts, using the normalized cache adds a lot of overhead, including large cache size. When that's the case, it is desirable to be able to manage the persistence of Apollo types more directly, and Codable is the standard protocol to do so. This PR provides a solution for the serialization, and possibly for the deserialization when including
Apollo
as a dependency.Why not
Decodable
?I think types can be decoded from a JSON value using
which in my understanding has the benefit of going through all the Apollo machinery to validate the data, detect fragment conformance etc. If this understanding is correct this is great. However this code depends on
Apollo
, notApolloAPI
so this is not something the generated code can depend on.