Skip to content

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

@calvincestari

Description

@calvincestari

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenIssues related to or arising from code generationfeatureNew addition or enhancement to existing solutionsv1.x

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions