diff --git a/codegen/input.gotpl b/codegen/input.gotpl index e8a5b50492b..c6eac4d47bb 100644 --- a/codegen/input.gotpl +++ b/codegen/input.gotpl @@ -2,7 +2,10 @@ {{- if not .HasUnmarshal }} func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, obj interface{}) ({{.Type | ref}}, error) { var it {{.Type | ref}} - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } {{ range $field := .Fields}} {{- if $field.Default}} if _, present := asMap[{{$field.Name|quote}}] ; !present { diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 497b5e7b65c..e2d59510a01 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -9873,7 +9873,10 @@ func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.Collected func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, obj interface{}) (InnerDirectives, error) { var it InnerDirectives - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -9915,7 +9918,10 @@ func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, o func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj interface{}) (InnerInput, error) { var it InnerInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -9935,7 +9941,10 @@ func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj in func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, obj interface{}) (InputDirectives, error) { var it InputDirectives - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -10055,7 +10064,10 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context, obj interface{}) (InputWithEnumValue, error) { var it InputWithEnumValue - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -10075,7 +10087,10 @@ func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj interface{}) (NestedInput, error) { var it NestedInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -10095,7 +10110,10 @@ func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj i func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, obj interface{}) (NestedMapInput, error) { var it NestedMapInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -10115,7 +10133,10 @@ func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, ob func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj interface{}) (OuterInput, error) { var it OuterInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -10135,7 +10156,10 @@ func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj in func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, obj interface{}) (RecursiveInputSlice, error) { var it RecursiveInputSlice - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -10155,7 +10179,10 @@ func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Contex func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj interface{}) (SpecialInput, error) { var it SpecialInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -10175,7 +10202,10 @@ func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj func (ec *executionContext) unmarshalInputValidInput(ctx context.Context, obj interface{}) (ValidInput, error) { var it ValidInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { diff --git a/example/config/generated.go b/example/config/generated.go index b4916887c53..cfb6c70d2f9 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -1844,7 +1844,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj interface{}) (NewTodo, error) { var it NewTodo - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { diff --git a/example/fileupload/generated.go b/example/fileupload/generated.go index 5aa3d87c0c8..bd1176864b8 100644 --- a/example/fileupload/generated.go +++ b/example/fileupload/generated.go @@ -1923,7 +1923,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co func (ec *executionContext) unmarshalInputUploadFile(ctx context.Context, obj interface{}) (model.UploadFile, error) { var it model.UploadFile - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { diff --git a/example/scalars/generated.go b/example/scalars/generated.go index fcfcba5244f..344dcb6f15b 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -2181,7 +2181,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co func (ec *executionContext) unmarshalInputSearchArgs(ctx context.Context, obj interface{}) (model.SearchArgs, error) { var it model.SearchArgs - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index 5034214bfcd..2fd0cbe2e36 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -3519,7 +3519,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co func (ec *executionContext) unmarshalInputReviewInput(ctx context.Context, obj interface{}) (models.Review, error) { var it models.Review - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { diff --git a/example/todo/generated.go b/example/todo/generated.go index 8c467913b0e..48855b3a4b8 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -1888,7 +1888,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj interface{}) (TodoInput, error) { var it TodoInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 09cc17b5a86..9b27fddd680 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -1909,7 +1909,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj interface{}) (TodoInput, error) { var it TodoInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { diff --git a/integration/generated.go b/integration/generated.go index 12ea40452ad..ded2c49f00e 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -2048,7 +2048,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co func (ec *executionContext) unmarshalInputDateFilter(ctx context.Context, obj interface{}) (models.DateFilter, error) { var it models.DateFilter - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } if _, present := asMap["timezone"]; !present { asMap["timezone"] = "UTC"