Hi,
I'm kinda new to Apollo iOS, so sorry if my question is kinda stupid. I'm passing a lot of data around in my (SwiftUI) app and the typing kinda drives me crazy. Right now I'm accepting arguments with types like LetterPartsQuery.Data.ArtistsSplittedInLetterPart.Artist & HomePageQuery.Data.Post.Artist and it's becoming harder and harder to manage this.
What's the quickest way to having easier types to juggle arround (like just Artist in my example above).
Thanks a lot!
I'm a firm believer in "There's no such thing as a stupid question, only an asshole answer." 馃槆 That said, this is definitely NOT a stupid question.
One thing that helps explain the way we generate this code is that for each operation, we only want to make available those properties and types that you've actually requested, rather than all possible properties and types. This means we have some fairly nested structures like the ones you're seeing.
One work around for this is to use GraphQL fragments. Our codegen will take anyplace that uses a fragment and generate a fragment type that can be reused across multiple operations.
They're still more annoying to use than I'd like (this is something I'm working on in Swift Codegen, but that's slightly blocked at the moment), but they are at least the same reusable type.
Does that help?
Thanks a lot! This will make my code readable again 馃槃
Most helpful comment
I'm a firm believer in "There's no such thing as a stupid question, only an asshole answer." 馃槆 That said, this is definitely NOT a stupid question.
One thing that helps explain the way we generate this code is that for each operation, we only want to make available those properties and types that you've actually requested, rather than all possible properties and types. This means we have some fairly nested structures like the ones you're seeing.
One work around for this is to use GraphQL fragments. Our codegen will take anyplace that uses a fragment and generate a fragment type that can be reused across multiple operations.
They're still more annoying to use than I'd like (this is something I'm working on in Swift Codegen, but that's slightly blocked at the moment), but they are at least the same reusable type.
Does that help?