From 861a805c7ae8128d2aa61ec1b9ba72bb28cec024 Mon Sep 17 00:00:00 2001 From: Evan Shaw Date: Mon, 3 Sep 2018 20:07:41 +1200 Subject: [PATCH] Regenerate code --- codegen/testserver/generated.go | 770 +++++++++++++++++--------------- example/chat/generated.go | 212 +++++---- example/config/generated.go | 116 +++-- example/dataloader/generated.go | 211 +++++---- example/scalars/generated.go | 145 +++--- example/selection/generated.go | 87 ++-- example/starwars/generated.go | 561 ++++++++++++++--------- example/todo/generated.go | 222 +++++---- integration/generated.go | 184 +++++--- 9 files changed, 1504 insertions(+), 1004 deletions(-) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 6df8c0247f2..af8a902340c 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -111,6 +111,383 @@ type QueryResolver interface { KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) } +func field_Query_mapInput_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *map[string]interface{} + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 map[string]interface{} + if tmp != nil { + ptr1 = tmp.(map[string]interface{}) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil + +} + +func field_Query_recursive_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *RecursiveInputSlice + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 RecursiveInputSlice + if tmp != nil { + ptr1, err = UnmarshalRecursiveInputSlice(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil + +} + +func field_Query_nestedInputs_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 [][]*OuterInput + if tmp, ok := rawArgs["input"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([][]*OuterInput, len(rawIf1)) + for idx1 := range rawIf1 { + var rawIf2 []interface{} + if rawIf1[idx1] != nil { + if tmp1, ok := rawIf1[idx1].([]interface{}); ok { + rawIf2 = tmp1 + } else { + rawIf2 = []interface{}{rawIf1[idx1]} + } + } + arg0[idx1] = make([]*OuterInput, len(rawIf2)) + for idx2 := range rawIf2 { + var ptr3 OuterInput + if rawIf2[idx2] != nil { + ptr3, err = UnmarshalOuterInput(rawIf2[idx2]) + arg0[idx1][idx2] = &ptr3 + } + } + } + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil + +} + +func field_Query_keywords_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *Keywords + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 Keywords + if tmp != nil { + ptr1, err = UnmarshalKeywords(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil + +} + +func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["break"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["break"] = arg0 + var arg1 string + if tmp, ok := rawArgs["default"]; ok { + var err error + arg1, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["default"] = arg1 + var arg2 string + if tmp, ok := rawArgs["func"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["func"] = arg2 + var arg3 string + if tmp, ok := rawArgs["interface"]; ok { + var err error + arg3, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["interface"] = arg3 + var arg4 string + if tmp, ok := rawArgs["select"]; ok { + var err error + arg4, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["select"] = arg4 + var arg5 string + if tmp, ok := rawArgs["case"]; ok { + var err error + arg5, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["case"] = arg5 + var arg6 string + if tmp, ok := rawArgs["defer"]; ok { + var err error + arg6, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["defer"] = arg6 + var arg7 string + if tmp, ok := rawArgs["go"]; ok { + var err error + arg7, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["go"] = arg7 + var arg8 string + if tmp, ok := rawArgs["map"]; ok { + var err error + arg8, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["map"] = arg8 + var arg9 string + if tmp, ok := rawArgs["struct"]; ok { + var err error + arg9, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["struct"] = arg9 + var arg10 string + if tmp, ok := rawArgs["chan"]; ok { + var err error + arg10, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["chan"] = arg10 + var arg11 string + if tmp, ok := rawArgs["else"]; ok { + var err error + arg11, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["else"] = arg11 + var arg12 string + if tmp, ok := rawArgs["goto"]; ok { + var err error + arg12, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["goto"] = arg12 + var arg13 string + if tmp, ok := rawArgs["package"]; ok { + var err error + arg13, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["package"] = arg13 + var arg14 string + if tmp, ok := rawArgs["switch"]; ok { + var err error + arg14, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["switch"] = arg14 + var arg15 string + if tmp, ok := rawArgs["const"]; ok { + var err error + arg15, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["const"] = arg15 + var arg16 string + if tmp, ok := rawArgs["fallthrough"]; ok { + var err error + arg16, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["fallthrough"] = arg16 + var arg17 string + if tmp, ok := rawArgs["if"]; ok { + var err error + arg17, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["if"] = arg17 + var arg18 string + if tmp, ok := rawArgs["range"]; ok { + var err error + arg18, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["range"] = arg18 + var arg19 string + if tmp, ok := rawArgs["type"]; ok { + var err error + arg19, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["type"] = arg19 + var arg20 string + if tmp, ok := rawArgs["continue"]; ok { + var err error + arg20, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["continue"] = arg20 + var arg21 string + if tmp, ok := rawArgs["for"]; ok { + var err error + arg21, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["for"] = arg21 + var arg22 string + if tmp, ok := rawArgs["import"]; ok { + var err error + arg22, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["import"] = arg22 + var arg23 string + if tmp, ok := rawArgs["return"]; ok { + var err error + arg23, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["return"] = arg23 + var arg24 string + if tmp, ok := rawArgs["var"]; ok { + var err error + arg24, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["var"] = arg24 + return args, nil + +} + +func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -1294,22 +1671,11 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. // nolint: vetshadow func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 *map[string]interface{} - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 map[string]interface{} - if tmp != nil { - ptr1 = tmp.(map[string]interface{}) - arg0 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_mapInput_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["input"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1334,22 +1700,11 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C // nolint: vetshadow func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 *RecursiveInputSlice - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 RecursiveInputSlice - if tmp != nil { - ptr1, err = UnmarshalRecursiveInputSlice(tmp) - arg0 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_recursive_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["input"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1374,43 +1729,11 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. // nolint: vetshadow func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 [][]*OuterInput - if tmp, ok := rawArgs["input"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([][]*OuterInput, len(rawIf1)) - for idx1 := range rawIf1 { - var rawIf2 []interface{} - if rawIf1[idx1] != nil { - if tmp1, ok := rawIf1[idx1].([]interface{}); ok { - rawIf2 = tmp1 - } else { - rawIf2 = []interface{}{rawIf1[idx1]} - } - } - arg0[idx1] = make([]*OuterInput, len(rawIf2)) - for idx2 := range rawIf2 { - var ptr3 OuterInput - if rawIf2[idx2] != nil { - ptr3, err = UnmarshalOuterInput(rawIf2[idx2]) - arg0[idx1][idx2] = &ptr3 - } - } - } - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_nestedInputs_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["input"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1522,22 +1845,11 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap // nolint: vetshadow func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 *Keywords - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 Keywords - if tmp != nil { - ptr1, err = UnmarshalKeywords(tmp) - arg0 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_keywords_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["input"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1663,257 +1975,11 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll // nolint: vetshadow func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["break"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["break"] = arg0 - var arg1 string - if tmp, ok := rawArgs["default"]; ok { - var err error - arg1, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["default"] = arg1 - var arg2 string - if tmp, ok := rawArgs["func"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["func"] = arg2 - var arg3 string - if tmp, ok := rawArgs["interface"]; ok { - var err error - arg3, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["interface"] = arg3 - var arg4 string - if tmp, ok := rawArgs["select"]; ok { - var err error - arg4, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["select"] = arg4 - var arg5 string - if tmp, ok := rawArgs["case"]; ok { - var err error - arg5, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["case"] = arg5 - var arg6 string - if tmp, ok := rawArgs["defer"]; ok { - var err error - arg6, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["defer"] = arg6 - var arg7 string - if tmp, ok := rawArgs["go"]; ok { - var err error - arg7, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["go"] = arg7 - var arg8 string - if tmp, ok := rawArgs["map"]; ok { - var err error - arg8, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["map"] = arg8 - var arg9 string - if tmp, ok := rawArgs["struct"]; ok { - var err error - arg9, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["struct"] = arg9 - var arg10 string - if tmp, ok := rawArgs["chan"]; ok { - var err error - arg10, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["chan"] = arg10 - var arg11 string - if tmp, ok := rawArgs["else"]; ok { - var err error - arg11, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["else"] = arg11 - var arg12 string - if tmp, ok := rawArgs["goto"]; ok { - var err error - arg12, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["goto"] = arg12 - var arg13 string - if tmp, ok := rawArgs["package"]; ok { - var err error - arg13, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["package"] = arg13 - var arg14 string - if tmp, ok := rawArgs["switch"]; ok { - var err error - arg14, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["switch"] = arg14 - var arg15 string - if tmp, ok := rawArgs["const"]; ok { - var err error - arg15, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["const"] = arg15 - var arg16 string - if tmp, ok := rawArgs["fallthrough"]; ok { - var err error - arg16, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["fallthrough"] = arg16 - var arg17 string - if tmp, ok := rawArgs["if"]; ok { - var err error - arg17, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["if"] = arg17 - var arg18 string - if tmp, ok := rawArgs["range"]; ok { - var err error - arg18, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["range"] = arg18 - var arg19 string - if tmp, ok := rawArgs["type"]; ok { - var err error - arg19, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["type"] = arg19 - var arg20 string - if tmp, ok := rawArgs["continue"]; ok { - var err error - arg20, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["continue"] = arg20 - var arg21 string - if tmp, ok := rawArgs["for"]; ok { - var err error - arg21, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["for"] = arg21 - var arg22 string - if tmp, ok := rawArgs["import"]; ok { - var err error - arg22, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["import"] = arg22 - var arg23 string - if tmp, ok := rawArgs["return"]; ok { - var err error - arg23, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["return"] = arg23 - var arg24 string - if tmp, ok := rawArgs["var"]; ok { - var err error - arg24, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_keywordArgs_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["var"] = arg24 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1937,17 +2003,11 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq // nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -3066,17 +3126,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -3234,17 +3288,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, diff --git a/example/chat/generated.go b/example/chat/generated.go index bf6fa37438d..2e32dbdb174 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -75,6 +75,114 @@ type SubscriptionResolver interface { MessageAdded(ctx context.Context, roomName string) (<-chan Message, error) } +func field_Mutation_post_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["text"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["text"] = arg0 + var arg1 string + if tmp, ok := rawArgs["username"]; ok { + var err error + arg1, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["username"] = arg1 + var arg2 string + if tmp, ok := rawArgs["roomName"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["roomName"] = arg2 + return args, nil + +} + +func field_Query_room_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field_Subscription_messageAdded_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["roomName"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["roomName"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -555,37 +663,11 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) // nolint: vetshadow func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["text"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["text"] = arg0 - var arg1 string - if tmp, ok := rawArgs["username"]; ok { - var err error - arg1, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["username"] = arg1 - var arg2 string - if tmp, ok := rawArgs["roomName"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Mutation_post_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["roomName"] = arg2 rctx := &graphql.ResolverContext{ Object: "Mutation", Args: args, @@ -650,17 +732,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr // nolint: vetshadow func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_room_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -686,17 +762,11 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle // nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -766,17 +836,11 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["roomName"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return nil - } + args, err := field_Subscription_messageAdded_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil } - args["roomName"] = arg0 ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, }) @@ -1782,17 +1846,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -1950,17 +2008,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, diff --git a/example/config/generated.go b/example/config/generated.go index 55bf813481a..e7c31473638 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -71,6 +71,66 @@ type TodoResolver interface { ID(ctx context.Context, obj *Todo) (string, error) } +func field_Mutation_createTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 NewTodo + if tmp, ok := rawArgs["input"]; ok { + var err error + arg0, err = UnmarshalNewTodo(tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil + +} + +func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -240,17 +300,11 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) // nolint: vetshadow func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 NewTodo - if tmp, ok := rawArgs["input"]; ok { - var err error - arg0, err = UnmarshalNewTodo(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Mutation_createTodo_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["input"] = arg0 rctx := &graphql.ResolverContext{ Object: "Mutation", Args: args, @@ -373,17 +427,11 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll // nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1659,17 +1707,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -1827,17 +1869,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index dec0733dd78..d9c424dc095 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -84,6 +84,114 @@ type QueryResolver interface { Torture2d(ctx context.Context, customerIds [][]int) ([][]Customer, error) } +func field_Query_torture1d_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 []int + if tmp, ok := rawArgs["customerIds"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([]int, len(rawIf1)) + for idx1 := range rawIf1 { + arg0[idx1], err = graphql.UnmarshalInt(rawIf1[idx1]) + } + if err != nil { + return nil, err + } + } + args["customerIds"] = arg0 + return args, nil + +} + +func field_Query_torture2d_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 [][]int + if tmp, ok := rawArgs["customerIds"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([][]int, len(rawIf1)) + for idx1 := range rawIf1 { + var rawIf2 []interface{} + if rawIf1[idx1] != nil { + if tmp1, ok := rawIf1[idx1].([]interface{}); ok { + rawIf2 = tmp1 + } else { + rawIf2 = []interface{}{rawIf1[idx1]} + } + } + arg0[idx1] = make([]int, len(rawIf2)) + for idx2 := range rawIf2 { + arg0[idx1][idx2], err = graphql.UnmarshalInt(rawIf2[idx2]) + } + } + if err != nil { + return nil, err + } + } + args["customerIds"] = arg0 + return args, nil + +} + +func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -888,28 +996,11 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. // nolint: vetshadow func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 []int - if tmp, ok := rawArgs["customerIds"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([]int, len(rawIf1)) - for idx1 := range rawIf1 { - arg0[idx1], err = graphql.UnmarshalInt(rawIf1[idx1]) - } - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_torture1d_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["customerIds"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -963,39 +1054,11 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. // nolint: vetshadow func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 [][]int - if tmp, ok := rawArgs["customerIds"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([][]int, len(rawIf1)) - for idx1 := range rawIf1 { - var rawIf2 []interface{} - if rawIf1[idx1] != nil { - if tmp1, ok := rawIf1[idx1].([]interface{}); ok { - rawIf2 = tmp1 - } else { - rawIf2 = []interface{}{rawIf1[idx1]} - } - } - arg0[idx1] = make([]int, len(rawIf2)) - for idx2 := range rawIf2 { - arg0[idx1][idx2], err = graphql.UnmarshalInt(rawIf2[idx2]) - } - } - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_torture2d_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["customerIds"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1080,17 +1143,11 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. // nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -2121,17 +2178,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -2289,17 +2340,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 3728f5f46d9..e766666af79 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -72,6 +72,81 @@ type UserResolver interface { CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) } +func field_Query_user_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 external.ObjectID + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = model.UnmarshalID(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil + +} + +func field_Query_search_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 model.SearchArgs + if tmp, ok := rawArgs["input"]; ok { + var err error + arg0, err = UnmarshalSearchArgs(tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil + +} + +func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -353,17 +428,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr // nolint: vetshadow func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 external.ObjectID - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = model.UnmarshalID(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_user_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["id"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -389,17 +458,11 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle // nolint: vetshadow func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 model.SearchArgs - if tmp, ok := rawArgs["input"]; ok { - var err error - arg0, err = UnmarshalSearchArgs(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_search_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["input"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -456,17 +519,11 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col // nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1730,17 +1787,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -1898,17 +1949,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, diff --git a/example/selection/generated.go b/example/selection/generated.go index c1b243601e9..1935eb07726 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -62,6 +62,51 @@ type QueryResolver interface { Events(ctx context.Context) ([]Event, error) } +func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -544,17 +589,11 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col // nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1585,17 +1624,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -1753,17 +1786,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, diff --git a/example/starwars/generated.go b/example/starwars/generated.go index a33e4c4f355..d89ba8d5704 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -140,6 +140,292 @@ type StarshipResolver interface { Length(ctx context.Context, obj *Starship, unit LengthUnit) (float64, error) } +func field_Droid_friendsConnection_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["first"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["first"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalID(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["after"] = arg1 + return args, nil + +} + +func field_Human_height_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 LengthUnit + if tmp, ok := rawArgs["unit"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["unit"] = arg0 + return args, nil + +} + +func field_Human_friendsConnection_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["first"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["first"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalID(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["after"] = arg1 + return args, nil + +} + +func field_Mutation_createReview_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["episode"] = arg0 + var arg1 Review + if tmp, ok := rawArgs["review"]; ok { + var err error + arg1, err = UnmarshalReviewInput(tmp) + if err != nil { + return nil, err + } + } + args["review"] = arg1 + return args, nil + +} + +func field_Query_hero_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["episode"] = arg0 + return args, nil + +} + +func field_Query_reviews_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["episode"] = arg0 + var arg1 *time.Time + if tmp, ok := rawArgs["since"]; ok { + var err error + var ptr1 time.Time + if tmp != nil { + ptr1, err = graphql.UnmarshalTime(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["since"] = arg1 + return args, nil + +} + +func field_Query_search_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["text"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["text"] = arg0 + return args, nil + +} + +func field_Query_character_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil + +} + +func field_Query_droid_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil + +} + +func field_Query_human_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil + +} + +func field_Query_starship_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil + +} + +func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field_Starship_length_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 LengthUnit + if tmp, ok := rawArgs["unit"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["unit"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -818,37 +1104,11 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co // nolint: vetshadow func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["first"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["first"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["after"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalID(tmp) - arg1 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Droid_friendsConnection_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["after"] = arg1 rctx := &graphql.ResolverContext{ Object: "Droid", Args: args, @@ -1307,17 +1567,11 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle // nolint: vetshadow func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 LengthUnit - if tmp, ok := rawArgs["unit"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Human_height_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["unit"] = arg0 rctx := &graphql.ResolverContext{ Object: "Human", Args: args, @@ -1412,37 +1666,11 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co // nolint: vetshadow func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["first"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["first"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["after"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalID(tmp) - arg1 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Human_friendsConnection_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["after"] = arg1 rctx := &graphql.ResolverContext{ Object: "Human", Args: args, @@ -1581,27 +1809,11 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) // nolint: vetshadow func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["episode"] = arg0 - var arg1 Review - if tmp, ok := rawArgs["review"]; ok { - var err error - arg1, err = UnmarshalReviewInput(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Mutation_createReview_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["review"] = arg1 rctx := &graphql.ResolverContext{ Object: "Mutation", Args: args, @@ -1815,17 +2027,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr // nolint: vetshadow func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_hero_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["episode"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1847,32 +2053,11 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle // nolint: vetshadow func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["episode"] = arg0 - var arg1 *time.Time - if tmp, ok := rawArgs["since"]; ok { - var err error - var ptr1 time.Time - if tmp != nil { - ptr1, err = graphql.UnmarshalTime(tmp) - arg1 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_reviews_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["since"] = arg1 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1929,17 +2114,11 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co // nolint: vetshadow func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["text"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_search_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["text"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1996,17 +2175,11 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col // nolint: vetshadow func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_character_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["id"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -2028,17 +2201,11 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. // nolint: vetshadow func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_droid_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["id"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -2064,17 +2231,11 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll // nolint: vetshadow func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_human_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["id"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -2100,17 +2261,11 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll // nolint: vetshadow func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_starship_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["id"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -2136,17 +2291,11 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C // nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -2388,17 +2537,11 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co // nolint: vetshadow func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 LengthUnit - if tmp, ok := rawArgs["unit"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Starship_length_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["unit"] = arg0 rctx := &graphql.ResolverContext{ Object: "Starship", Args: args, @@ -3443,17 +3586,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -3611,17 +3748,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, diff --git a/example/todo/generated.go b/example/todo/generated.go index e98ab8b48bd..364336c9de6 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -67,6 +67,120 @@ type MyQueryResolver interface { Todos(ctx context.Context) ([]Todo, error) } +func field_MyMutation_createTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 TodoInput + if tmp, ok := rawArgs["todo"]; ok { + var err error + arg0, err = UnmarshalTodoInput(tmp) + if err != nil { + return nil, err + } + } + args["todo"] = arg0 + return args, nil + +} + +func field_MyMutation_updateTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + var arg1 map[string]interface{} + if tmp, ok := rawArgs["changes"]; ok { + var err error + arg1 = tmp.(map[string]interface{}) + if err != nil { + return nil, err + } + } + args["changes"] = arg1 + return args, nil + +} + +func field_MyQuery_todo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil + +} + +func field_MyQuery___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func dir_hasRole_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Role + if tmp, ok := rawArgs["role"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["role"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -263,17 +377,11 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe // nolint: vetshadow func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 TodoInput - if tmp, ok := rawArgs["todo"]; ok { - var err error - arg0, err = UnmarshalTodoInput(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_MyMutation_createTodo_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["todo"] = arg0 rctx := &graphql.ResolverContext{ Object: "MyMutation", Args: args, @@ -298,27 +406,11 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr // nolint: vetshadow func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - } - args["id"] = arg0 - var arg1 map[string]interface{} - if tmp, ok := rawArgs["changes"]; ok { - var err error - arg1 = tmp.(map[string]interface{}) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_MyMutation_updateTodo_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["changes"] = arg1 rctx := &graphql.ResolverContext{ Object: "MyMutation", Args: args, @@ -399,17 +491,11 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) // nolint: vetshadow func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_MyQuery_todo_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["id"] = arg0 rctx := &graphql.ResolverContext{ Object: "MyQuery", Args: args, @@ -514,17 +600,11 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co // nolint: vetshadow func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_MyQuery___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "MyQuery", Args: args, @@ -1661,17 +1741,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -1829,17 +1903,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -2008,17 +2076,11 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} case "hasRole": if ec.directives.HasRole != nil { rawArgs := d.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 Role - if tmp, ok := rawArgs["role"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := dir_hasRole_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil } - args["role"] = arg0 n := next next = func(ctx context.Context) (interface{}, error) { return ec.directives.HasRole(ctx, obj, n, args["role"].(Role)) diff --git a/integration/generated.go b/integration/generated.go index 02581e1ddb7..b9c39ef6858 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -82,6 +82,101 @@ type UserResolver interface { Likes(ctx context.Context, obj *remote_api.User) ([]string, error) } +func field_Query_date_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 models.DateFilter + if tmp, ok := rawArgs["filter"]; ok { + var err error + arg0, err = UnmarshalDateFilter(tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil + +} + +func field_Query_error_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 models.ErrorType + if tmp, ok := rawArgs["type"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["type"] = arg0 + return args, nil + +} + +func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func dir_magic_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["kind"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["kind"] = arg0 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -482,17 +577,11 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle // nolint: vetshadow func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 models.DateFilter - if tmp, ok := rawArgs["filter"]; ok { - var err error - arg0, err = UnmarshalDateFilter(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_date_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["filter"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -562,17 +651,11 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 models.ErrorType - if tmp, ok := rawArgs["type"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query_error_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["type"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -596,17 +679,11 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll // nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field_Query___type_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["name"] = arg0 rctx := &graphql.ResolverContext{ Object: "Query", Args: args, @@ -1781,17 +1858,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph // nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_fields_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -1949,17 +2020,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra // nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := field___Type_enumValues_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["includeDeprecated"] = arg0 rctx := &graphql.ResolverContext{ Object: "__Type", Args: args, @@ -2146,22 +2211,11 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} case "magic": if ec.directives.Magic != nil { rawArgs := d.ArgumentMap(ec.Variables) - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["kind"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + args, err := dir_magic_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil } - args["kind"] = arg0 n := next next = func(ctx context.Context) (interface{}, error) { return ec.directives.Magic(ctx, obj, n, args["kind"].(*int))