apollo-ios icon indicating copy to clipboard operation
apollo-ios copied to clipboard

1.x Feature - Directive to extend fields with protocol conformance

Open calvincestari opened this issue 2 years ago • 2 comments

To be clearer about my proposal, I mean something like this:

/// You define this protocol
protocol CharacterName {
    var name: String { get }
}

/// You define this extension
extension CharacterName {
    var nameAllCaps: String { self.name.uppercased() }
}

In your graphql query:

query {
    hero @extends("CharacterName") {
        id
        name
    }
}
/// The directive would make the generated code add this extension for the generated type.
extension HeroDetailsQuery.Data.Hero: CharacterName {}

Would that be adequate for you @Mordil? It's not totally automatic, but it is cleaner and easier than the status quo.

calvincestari avatar May 23 '22 21:05 calvincestari

Yes, that is adequate and seems to address many cross-cutting concerns.

Thanks for keeping up with this request!

Mordil avatar May 24 '22 20:05 Mordil

Haha, sorry, we didn't mean to copy over tagging you! I know we already had this conversation :)

AnthonyMDev avatar May 25 '22 23:05 AnthonyMDev