From 79b3d189186783c01acb194de825976a007dbd5f Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Mon, 30 Jul 2018 00:20:04 +0200 Subject: graphql: use an interface instead of an union for the operations for easier query --- graphql/graph/gen_graph.go | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) (limited to 'graphql/graph') diff --git a/graphql/graph/gen_graph.go b/graphql/graph/gen_graph.go index 386e9d01..b747e9d4 100644 --- a/graphql/graph/gen_graph.go +++ b/graphql/graph/gen_graph.go @@ -1060,7 +1060,7 @@ func (ec *executionContext) _OperationEdge_node(ctx context.Context, field graph rctx.PushField(field.Alias) defer rctx.Pop() res := obj.Node - return ec._OperationUnion(ctx, field.Selections, &res) + return ec._Operation(ctx, field.Selections, &res) } var pageInfoImplementors = []string{"PageInfo"} @@ -2345,35 +2345,6 @@ func (ec *executionContext) _Operation(ctx context.Context, sel []query.Selectio } } -func (ec *executionContext) _OperationUnion(ctx context.Context, sel []query.Selection, obj *models.OperationUnion) graphql.Marshaler { - switch obj := (*obj).(type) { - case nil: - return graphql.Null - case operations.CreateOperation: - return ec._CreateOperation(ctx, sel, &obj) - case *operations.CreateOperation: - return ec._CreateOperation(ctx, sel, obj) - case operations.SetTitleOperation: - return ec._SetTitleOperation(ctx, sel, &obj) - case *operations.SetTitleOperation: - return ec._SetTitleOperation(ctx, sel, obj) - case operations.AddCommentOperation: - return ec._AddCommentOperation(ctx, sel, &obj) - case *operations.AddCommentOperation: - return ec._AddCommentOperation(ctx, sel, obj) - case operations.SetStatusOperation: - return ec._SetStatusOperation(ctx, sel, &obj) - case *operations.SetStatusOperation: - return ec._SetStatusOperation(ctx, sel, obj) - case operations.LabelChangeOperation: - return ec._LabelChangeOperation(ctx, sel, &obj) - case *operations.LabelChangeOperation: - return ec._LabelChangeOperation(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - func UnmarshalConnectionInput(v interface{}) (models.ConnectionInput, error) { var it models.ConnectionInput var asMap = v.(map[string]interface{}) @@ -2523,7 +2494,7 @@ type OperationConnection { type OperationEdge { cursor: String! - node: OperationUnion! + node: Operation! } # An operation applied to a bug. @@ -2572,13 +2543,6 @@ type LabelChangeOperation implements Operation, Authored { removed: [Label!]! } -union OperationUnion = - CreateOperation - | SetTitleOperation - | AddCommentOperation - | SetStatusOperation - | LabelChangeOperation - # The connection type for Bug. type BugConnection { # A list of edges. -- cgit