github.com/senomas/gqlgen@v0.17.11-0.20220626120754-9aee61b0716a/codegen/testserver/followschema/maps.generated.go (about) 1 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "errors" 8 "fmt" 9 "strconv" 10 11 "github.com/99designs/gqlgen/graphql" 12 "github.com/vektah/gqlparser/v2/ast" 13 ) 14 15 // region ************************** generated!.gotpl ************************** 16 17 // endregion ************************** generated!.gotpl ************************** 18 19 // region ***************************** args.gotpl ***************************** 20 21 // endregion ***************************** args.gotpl ***************************** 22 23 // region ************************** directives.gotpl ************************** 24 25 // endregion ************************** directives.gotpl ************************** 26 27 // region **************************** field.gotpl ***************************** 28 29 func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { 30 fc, err := ec.fieldContext_MapStringInterfaceType_a(ctx, field) 31 if err != nil { 32 return graphql.Null 33 } 34 ctx = graphql.WithFieldContext(ctx, fc) 35 defer func() { 36 if r := recover(); r != nil { 37 ec.Error(ctx, ec.Recover(ctx, r)) 38 ret = graphql.Null 39 } 40 }() 41 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 42 ctx = rctx // use context from middleware stack in children 43 switch v := obj["a"].(type) { 44 case *string: 45 return v, nil 46 case string: 47 return &v, nil 48 case nil: 49 return (*string)(nil), nil 50 default: 51 return nil, fmt.Errorf("unexpected type %T for field %s", v, "a") 52 } 53 }) 54 55 if resTmp == nil { 56 return graphql.Null 57 } 58 res := resTmp.(*string) 59 fc.Result = res 60 return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 61 } 62 63 func (ec *executionContext) fieldContext_MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 64 fc = &graphql.FieldContext{ 65 Object: "MapStringInterfaceType", 66 Field: field, 67 IsMethod: false, 68 IsResolver: false, 69 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 70 return nil, errors.New("field of type String does not have child fields") 71 }, 72 } 73 return fc, nil 74 } 75 76 func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { 77 fc, err := ec.fieldContext_MapStringInterfaceType_b(ctx, field) 78 if err != nil { 79 return graphql.Null 80 } 81 ctx = graphql.WithFieldContext(ctx, fc) 82 defer func() { 83 if r := recover(); r != nil { 84 ec.Error(ctx, ec.Recover(ctx, r)) 85 ret = graphql.Null 86 } 87 }() 88 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 89 ctx = rctx // use context from middleware stack in children 90 switch v := obj["b"].(type) { 91 case *int: 92 return v, nil 93 case int: 94 return &v, nil 95 case nil: 96 return (*int)(nil), nil 97 default: 98 return nil, fmt.Errorf("unexpected type %T for field %s", v, "b") 99 } 100 }) 101 102 if resTmp == nil { 103 return graphql.Null 104 } 105 res := resTmp.(*int) 106 fc.Result = res 107 return ec.marshalOInt2ᚖint(ctx, field.Selections, res) 108 } 109 110 func (ec *executionContext) fieldContext_MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 111 fc = &graphql.FieldContext{ 112 Object: "MapStringInterfaceType", 113 Field: field, 114 IsMethod: false, 115 IsResolver: false, 116 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 117 return nil, errors.New("field of type Int does not have child fields") 118 }, 119 } 120 return fc, nil 121 } 122 123 // endregion **************************** field.gotpl ***************************** 124 125 // region **************************** input.gotpl ***************************** 126 127 func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, obj interface{}) (NestedMapInput, error) { 128 var it NestedMapInput 129 asMap := map[string]interface{}{} 130 for k, v := range obj.(map[string]interface{}) { 131 asMap[k] = v 132 } 133 134 for k, v := range asMap { 135 switch k { 136 case "map": 137 var err error 138 139 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) 140 it.Map, err = ec.unmarshalOMapStringInterfaceInput2map(ctx, v) 141 if err != nil { 142 return it, err 143 } 144 } 145 } 146 147 return it, nil 148 } 149 150 // endregion **************************** input.gotpl ***************************** 151 152 // region ************************** interface.gotpl *************************** 153 154 // endregion ************************** interface.gotpl *************************** 155 156 // region **************************** object.gotpl **************************** 157 158 var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"} 159 160 func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]interface{}) graphql.Marshaler { 161 fields := graphql.CollectFields(ec.OperationContext, sel, mapStringInterfaceTypeImplementors) 162 out := graphql.NewFieldSet(fields) 163 var invalids uint32 164 for i, field := range fields { 165 switch field.Name { 166 case "__typename": 167 out.Values[i] = graphql.MarshalString("MapStringInterfaceType") 168 case "a": 169 170 out.Values[i] = ec._MapStringInterfaceType_a(ctx, field, obj) 171 172 case "b": 173 174 out.Values[i] = ec._MapStringInterfaceType_b(ctx, field, obj) 175 176 default: 177 panic("unknown field " + strconv.Quote(field.Name)) 178 } 179 } 180 out.Dispatch() 181 if invalids > 0 { 182 return graphql.Null 183 } 184 return out 185 } 186 187 // endregion **************************** object.gotpl **************************** 188 189 // region ***************************** type.gotpl ***************************** 190 191 func (ec *executionContext) unmarshalOMapStringInterfaceInput2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { 192 if v == nil { 193 return nil, nil 194 } 195 return v.(map[string]interface{}), nil 196 } 197 198 func (ec *executionContext) marshalOMapStringInterfaceType2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { 199 if v == nil { 200 return graphql.Null 201 } 202 return ec._MapStringInterfaceType(ctx, sel, v) 203 } 204 205 func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedMapInput(ctx context.Context, v interface{}) (*NestedMapInput, error) { 206 if v == nil { 207 return nil, nil 208 } 209 res, err := ec.unmarshalInputNestedMapInput(ctx, v) 210 return &res, graphql.ErrorOnPath(ctx, err) 211 } 212 213 // endregion ***************************** type.gotpl *****************************