-
Notifications
You must be signed in to change notification settings - Fork 749
Open
Labels
codegenIssues related to or arising from code generationIssues related to or arising from code generationenhancementIssues outlining new things we want to do or things that will make our lives as devs easierIssues outlining new things we want to do or things that will make our lives as devs easierv1.x
Description
This is a feature request.
Current implementation
Given a Node interface type and A, B, and C types that conform to it, it the following schema:
interface Node {
id: ID!
}
type A implements Node {
id: ID!
name: String
}
# ... etc
type Query {
node: Node
}
the code generator for the following query
query NodeQuery {
node {
id
... on A {
name
}
}
}would generate code that has asA getter producing an optional of A swift type.
This means for N types, we have to write N if let valueA = data.node.asA clauses.
Proposal
Generate an enum for Node type that has all of the type's known implementors as cases.
enum Node {
case A(data: StructA)
case B(data: StructB)
// etc...
}which would allow for a simpler access of the interface values using a switch, while still allowing if ... else syntax using if case let.
Metadata
Metadata
Assignees
Labels
codegenIssues related to or arising from code generationIssues related to or arising from code generationenhancementIssues outlining new things we want to do or things that will make our lives as devs easierIssues outlining new things we want to do or things that will make our lives as devs easierv1.x