github.com/operandinc/gqlgen@v0.16.1/codegen/testserver/followschema/defaults.generated.go (about) 1 // Code generated by github.com/operandinc/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "strconv" 8 9 "github.com/operandinc/gqlgen/graphql" 10 "github.com/vektah/gqlparser/v2/ast" 11 ) 12 13 // region ************************** generated!.gotpl ************************** 14 15 type MutationResolver interface { 16 DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) 17 UpdateSomething(ctx context.Context, input SpecialInput) (string, error) 18 UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) 19 } 20 21 // endregion ************************** generated!.gotpl ************************** 22 23 // region ***************************** args.gotpl ***************************** 24 25 func (ec *executionContext) field_Mutation_defaultInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 26 var err error 27 args := map[string]interface{}{} 28 var arg0 DefaultInput 29 if tmp, ok := rawArgs["input"]; ok { 30 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) 31 arg0, err = ec.unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx, tmp) 32 if err != nil { 33 return nil, err 34 } 35 } 36 args["input"] = arg0 37 return args, nil 38 } 39 40 func (ec *executionContext) field_Mutation_updatePtrToPtr_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 41 var err error 42 args := map[string]interface{}{} 43 var arg0 UpdatePtrToPtrOuter 44 if tmp, ok := rawArgs["input"]; ok { 45 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) 46 arg0, err = ec.unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrOuter(ctx, tmp) 47 if err != nil { 48 return nil, err 49 } 50 } 51 args["input"] = arg0 52 return args, nil 53 } 54 55 func (ec *executionContext) field_Mutation_updateSomething_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 56 var err error 57 args := map[string]interface{}{} 58 var arg0 SpecialInput 59 if tmp, ok := rawArgs["input"]; ok { 60 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) 61 arg0, err = ec.unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSpecialInput(ctx, tmp) 62 if err != nil { 63 return nil, err 64 } 65 } 66 args["input"] = arg0 67 return args, nil 68 } 69 70 // endregion ***************************** args.gotpl ***************************** 71 72 // region ************************** directives.gotpl ************************** 73 74 // endregion ************************** directives.gotpl ************************** 75 76 // region **************************** field.gotpl ***************************** 77 78 func (ec *executionContext) _DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { 79 defer func() { 80 if r := recover(); r != nil { 81 ec.Error(ctx, ec.Recover(ctx, r)) 82 ret = graphql.Null 83 } 84 }() 85 fc := &graphql.FieldContext{ 86 Object: "DefaultParametersMirror", 87 Field: field, 88 Args: nil, 89 IsMethod: false, 90 IsResolver: false, 91 } 92 93 ctx = graphql.WithFieldContext(ctx, fc) 94 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 95 ctx = rctx // use context from middleware stack in children 96 return obj.FalsyBoolean, nil 97 }) 98 99 if resTmp == nil { 100 return graphql.Null 101 } 102 res := resTmp.(*bool) 103 fc.Result = res 104 return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) 105 } 106 107 func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { 108 defer func() { 109 if r := recover(); r != nil { 110 ec.Error(ctx, ec.Recover(ctx, r)) 111 ret = graphql.Null 112 } 113 }() 114 fc := &graphql.FieldContext{ 115 Object: "DefaultParametersMirror", 116 Field: field, 117 Args: nil, 118 IsMethod: false, 119 IsResolver: false, 120 } 121 122 ctx = graphql.WithFieldContext(ctx, fc) 123 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 124 ctx = rctx // use context from middleware stack in children 125 return obj.TruthyBoolean, nil 126 }) 127 128 if resTmp == nil { 129 return graphql.Null 130 } 131 res := resTmp.(*bool) 132 fc.Result = res 133 return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) 134 } 135 136 func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 137 defer func() { 138 if r := recover(); r != nil { 139 ec.Error(ctx, ec.Recover(ctx, r)) 140 ret = graphql.Null 141 } 142 }() 143 fc := &graphql.FieldContext{ 144 Object: "Mutation", 145 Field: field, 146 Args: nil, 147 IsMethod: true, 148 IsResolver: true, 149 } 150 151 ctx = graphql.WithFieldContext(ctx, fc) 152 rawArgs := field.ArgumentMap(ec.Variables) 153 args, err := ec.field_Mutation_defaultInput_args(ctx, rawArgs) 154 if err != nil { 155 ec.Error(ctx, err) 156 return graphql.Null 157 } 158 fc.Args = args 159 resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { 160 ctx = rctx // use context from middleware stack in children 161 return ec.resolvers.Mutation().DefaultInput(rctx, args["input"].(DefaultInput)) 162 }) 163 164 if resTmp == nil { 165 if !graphql.HasFieldError(ctx, fc) { 166 ec.Errorf(ctx, "must not be null") 167 } 168 return graphql.Null 169 } 170 res := resTmp.(*DefaultParametersMirror) 171 fc.Result = res 172 return ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx, field.Selections, res) 173 } 174 175 func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 176 defer func() { 177 if r := recover(); r != nil { 178 ec.Error(ctx, ec.Recover(ctx, r)) 179 ret = graphql.Null 180 } 181 }() 182 fc := &graphql.FieldContext{ 183 Object: "Mutation", 184 Field: field, 185 Args: nil, 186 IsMethod: true, 187 IsResolver: true, 188 } 189 190 ctx = graphql.WithFieldContext(ctx, fc) 191 rawArgs := field.ArgumentMap(ec.Variables) 192 args, err := ec.field_Mutation_updateSomething_args(ctx, rawArgs) 193 if err != nil { 194 ec.Error(ctx, err) 195 return graphql.Null 196 } 197 fc.Args = args 198 resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { 199 ctx = rctx // use context from middleware stack in children 200 return ec.resolvers.Mutation().UpdateSomething(rctx, args["input"].(SpecialInput)) 201 }) 202 203 if resTmp == nil { 204 if !graphql.HasFieldError(ctx, fc) { 205 ec.Errorf(ctx, "must not be null") 206 } 207 return graphql.Null 208 } 209 res := resTmp.(string) 210 fc.Result = res 211 return ec.marshalNString2string(ctx, field.Selections, res) 212 } 213 214 func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 215 defer func() { 216 if r := recover(); r != nil { 217 ec.Error(ctx, ec.Recover(ctx, r)) 218 ret = graphql.Null 219 } 220 }() 221 fc := &graphql.FieldContext{ 222 Object: "Mutation", 223 Field: field, 224 Args: nil, 225 IsMethod: true, 226 IsResolver: true, 227 } 228 229 ctx = graphql.WithFieldContext(ctx, fc) 230 rawArgs := field.ArgumentMap(ec.Variables) 231 args, err := ec.field_Mutation_updatePtrToPtr_args(ctx, rawArgs) 232 if err != nil { 233 ec.Error(ctx, err) 234 return graphql.Null 235 } 236 fc.Args = args 237 resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { 238 ctx = rctx // use context from middleware stack in children 239 return ec.resolvers.Mutation().UpdatePtrToPtr(rctx, args["input"].(UpdatePtrToPtrOuter)) 240 }) 241 242 if resTmp == nil { 243 if !graphql.HasFieldError(ctx, fc) { 244 ec.Errorf(ctx, "must not be null") 245 } 246 return graphql.Null 247 } 248 res := resTmp.(*PtrToPtrOuter) 249 fc.Result = res 250 return ec.marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx, field.Selections, res) 251 } 252 253 // endregion **************************** field.gotpl ***************************** 254 255 // region **************************** input.gotpl ***************************** 256 257 func (ec *executionContext) unmarshalInputDefaultInput(ctx context.Context, obj interface{}) (DefaultInput, error) { 258 var it DefaultInput 259 asMap := map[string]interface{}{} 260 for k, v := range obj.(map[string]interface{}) { 261 asMap[k] = v 262 } 263 264 if _, present := asMap["falsyBoolean"]; !present { 265 asMap["falsyBoolean"] = false 266 } 267 if _, present := asMap["truthyBoolean"]; !present { 268 asMap["truthyBoolean"] = true 269 } 270 271 for k, v := range asMap { 272 switch k { 273 case "falsyBoolean": 274 var err error 275 276 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean")) 277 it.FalsyBoolean, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) 278 if err != nil { 279 return it, err 280 } 281 case "truthyBoolean": 282 var err error 283 284 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean")) 285 it.TruthyBoolean, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) 286 if err != nil { 287 return it, err 288 } 289 } 290 } 291 292 return it, nil 293 } 294 295 // endregion **************************** input.gotpl ***************************** 296 297 // region ************************** interface.gotpl *************************** 298 299 // endregion ************************** interface.gotpl *************************** 300 301 // region **************************** object.gotpl **************************** 302 303 var defaultParametersMirrorImplementors = []string{"DefaultParametersMirror"} 304 305 func (ec *executionContext) _DefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, obj *DefaultParametersMirror) graphql.Marshaler { 306 fields := graphql.CollectFields(ec.OperationContext, sel, defaultParametersMirrorImplementors) 307 out := graphql.NewFieldSet(fields) 308 var invalids uint32 309 for i, field := range fields { 310 switch field.Name { 311 case "__typename": 312 out.Values[i] = graphql.MarshalString("DefaultParametersMirror") 313 case "falsyBoolean": 314 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 315 return ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj) 316 } 317 318 out.Values[i] = innerFunc(ctx) 319 320 case "truthyBoolean": 321 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 322 return ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj) 323 } 324 325 out.Values[i] = innerFunc(ctx) 326 327 default: 328 panic("unknown field " + strconv.Quote(field.Name)) 329 } 330 } 331 out.Dispatch() 332 if invalids > 0 { 333 return graphql.Null 334 } 335 return out 336 } 337 338 var mutationImplementors = []string{"Mutation"} 339 340 func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 341 fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) 342 ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ 343 Object: "Mutation", 344 }) 345 346 out := graphql.NewFieldSet(fields) 347 var invalids uint32 348 for i, field := range fields { 349 innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ 350 Object: field.Name, 351 Field: field, 352 }) 353 354 switch field.Name { 355 case "__typename": 356 out.Values[i] = graphql.MarshalString("Mutation") 357 case "defaultInput": 358 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 359 return ec._Mutation_defaultInput(ctx, field) 360 } 361 362 out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) 363 364 if out.Values[i] == graphql.Null { 365 invalids++ 366 } 367 case "updateSomething": 368 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 369 return ec._Mutation_updateSomething(ctx, field) 370 } 371 372 out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) 373 374 if out.Values[i] == graphql.Null { 375 invalids++ 376 } 377 case "updatePtrToPtr": 378 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 379 return ec._Mutation_updatePtrToPtr(ctx, field) 380 } 381 382 out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, innerFunc) 383 384 if out.Values[i] == graphql.Null { 385 invalids++ 386 } 387 default: 388 panic("unknown field " + strconv.Quote(field.Name)) 389 } 390 } 391 out.Dispatch() 392 if invalids > 0 { 393 return graphql.Null 394 } 395 return out 396 } 397 398 // endregion **************************** object.gotpl **************************** 399 400 // region ***************************** type.gotpl ***************************** 401 402 func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx context.Context, v interface{}) (DefaultInput, error) { 403 res, err := ec.unmarshalInputDefaultInput(ctx, v) 404 return res, graphql.ErrorOnPath(ctx, err) 405 } 406 407 func (ec *executionContext) marshalNDefaultParametersMirror2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v DefaultParametersMirror) graphql.Marshaler { 408 return ec._DefaultParametersMirror(ctx, sel, &v) 409 } 410 411 func (ec *executionContext) marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v *DefaultParametersMirror) graphql.Marshaler { 412 if v == nil { 413 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 414 ec.Errorf(ctx, "must not be null") 415 } 416 return graphql.Null 417 } 418 return ec._DefaultParametersMirror(ctx, sel, v) 419 } 420 421 // endregion ***************************** type.gotpl *****************************