github.com/luciferinlove/gqlgen@v0.17.16-bzc.1/codegen/testserver/followschema/complexity.generated.go (about) 1 // Code generated by github.com/luciferinlove/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "errors" 8 "strconv" 9 "sync/atomic" 10 11 "github.com/luciferinlove/gqlgen/graphql" 12 "github.com/vektah/gqlparser/v2/ast" 13 ) 14 15 // region ************************** generated!.gotpl ************************** 16 17 type OverlappingFieldsResolver interface { 18 OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) 19 } 20 21 // endregion ************************** generated!.gotpl ************************** 22 23 // region ***************************** args.gotpl ***************************** 24 25 // endregion ***************************** args.gotpl ***************************** 26 27 // region ************************** directives.gotpl ************************** 28 29 // endregion ************************** directives.gotpl ************************** 30 31 // region **************************** field.gotpl ***************************** 32 33 func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { 34 fc, err := ec.fieldContext_OverlappingFields_oneFoo(ctx, field) 35 if err != nil { 36 return graphql.Null 37 } 38 ctx = graphql.WithFieldContext(ctx, fc) 39 defer func() { 40 if r := recover(); r != nil { 41 ec.Error(ctx, ec.Recover(ctx, r)) 42 ret = graphql.Null 43 } 44 }() 45 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 46 ctx = rctx // use context from middleware stack in children 47 return obj.Foo, nil 48 }) 49 50 if resTmp == nil { 51 if !graphql.HasFieldError(ctx, fc) { 52 ec.Errorf(ctx, "must not be null") 53 } 54 return graphql.Null 55 } 56 res := resTmp.(int) 57 fc.Result = res 58 return ec.marshalNInt2int(ctx, field.Selections, res) 59 } 60 61 func (ec *executionContext) fieldContext_OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 62 fc = &graphql.FieldContext{ 63 Object: "OverlappingFields", 64 Field: field, 65 IsMethod: false, 66 IsResolver: false, 67 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 68 return nil, errors.New("field of type Int does not have child fields") 69 }, 70 } 71 return fc, nil 72 } 73 74 func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { 75 fc, err := ec.fieldContext_OverlappingFields_twoFoo(ctx, field) 76 if err != nil { 77 return graphql.Null 78 } 79 ctx = graphql.WithFieldContext(ctx, fc) 80 defer func() { 81 if r := recover(); r != nil { 82 ec.Error(ctx, ec.Recover(ctx, r)) 83 ret = graphql.Null 84 } 85 }() 86 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 87 ctx = rctx // use context from middleware stack in children 88 return obj.Foo, nil 89 }) 90 91 if resTmp == nil { 92 if !graphql.HasFieldError(ctx, fc) { 93 ec.Errorf(ctx, "must not be null") 94 } 95 return graphql.Null 96 } 97 res := resTmp.(int) 98 fc.Result = res 99 return ec.marshalNInt2int(ctx, field.Selections, res) 100 } 101 102 func (ec *executionContext) fieldContext_OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 103 fc = &graphql.FieldContext{ 104 Object: "OverlappingFields", 105 Field: field, 106 IsMethod: false, 107 IsResolver: false, 108 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 109 return nil, errors.New("field of type Int does not have child fields") 110 }, 111 } 112 return fc, nil 113 } 114 115 func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { 116 fc, err := ec.fieldContext_OverlappingFields_oldFoo(ctx, field) 117 if err != nil { 118 return graphql.Null 119 } 120 ctx = graphql.WithFieldContext(ctx, fc) 121 defer func() { 122 if r := recover(); r != nil { 123 ec.Error(ctx, ec.Recover(ctx, r)) 124 ret = graphql.Null 125 } 126 }() 127 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 128 ctx = rctx // use context from middleware stack in children 129 return ec.resolvers.OverlappingFields().OldFoo(rctx, obj) 130 }) 131 132 if resTmp == nil { 133 if !graphql.HasFieldError(ctx, fc) { 134 ec.Errorf(ctx, "must not be null") 135 } 136 return graphql.Null 137 } 138 res := resTmp.(int) 139 fc.Result = res 140 return ec.marshalNInt2int(ctx, field.Selections, res) 141 } 142 143 func (ec *executionContext) fieldContext_OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 144 fc = &graphql.FieldContext{ 145 Object: "OverlappingFields", 146 Field: field, 147 IsMethod: true, 148 IsResolver: true, 149 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 150 return nil, errors.New("field of type Int does not have child fields") 151 }, 152 } 153 return fc, nil 154 } 155 156 func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { 157 fc, err := ec.fieldContext_OverlappingFields_newFoo(ctx, field) 158 if err != nil { 159 return graphql.Null 160 } 161 ctx = graphql.WithFieldContext(ctx, fc) 162 defer func() { 163 if r := recover(); r != nil { 164 ec.Error(ctx, ec.Recover(ctx, r)) 165 ret = graphql.Null 166 } 167 }() 168 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 169 ctx = rctx // use context from middleware stack in children 170 return obj.NewFoo, nil 171 }) 172 173 if resTmp == nil { 174 if !graphql.HasFieldError(ctx, fc) { 175 ec.Errorf(ctx, "must not be null") 176 } 177 return graphql.Null 178 } 179 res := resTmp.(int) 180 fc.Result = res 181 return ec.marshalNInt2int(ctx, field.Selections, res) 182 } 183 184 func (ec *executionContext) fieldContext_OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 185 fc = &graphql.FieldContext{ 186 Object: "OverlappingFields", 187 Field: field, 188 IsMethod: false, 189 IsResolver: false, 190 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 191 return nil, errors.New("field of type Int does not have child fields") 192 }, 193 } 194 return fc, nil 195 } 196 197 func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { 198 fc, err := ec.fieldContext_OverlappingFields_new_foo(ctx, field) 199 if err != nil { 200 return graphql.Null 201 } 202 ctx = graphql.WithFieldContext(ctx, fc) 203 defer func() { 204 if r := recover(); r != nil { 205 ec.Error(ctx, ec.Recover(ctx, r)) 206 ret = graphql.Null 207 } 208 }() 209 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 210 ctx = rctx // use context from middleware stack in children 211 return obj.NewFoo, nil 212 }) 213 214 if resTmp == nil { 215 if !graphql.HasFieldError(ctx, fc) { 216 ec.Errorf(ctx, "must not be null") 217 } 218 return graphql.Null 219 } 220 res := resTmp.(int) 221 fc.Result = res 222 return ec.marshalNInt2int(ctx, field.Selections, res) 223 } 224 225 func (ec *executionContext) fieldContext_OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 226 fc = &graphql.FieldContext{ 227 Object: "OverlappingFields", 228 Field: field, 229 IsMethod: false, 230 IsResolver: false, 231 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 232 return nil, errors.New("field of type Int does not have child fields") 233 }, 234 } 235 return fc, nil 236 } 237 238 // endregion **************************** field.gotpl ***************************** 239 240 // region **************************** input.gotpl ***************************** 241 242 // endregion **************************** input.gotpl ***************************** 243 244 // region ************************** interface.gotpl *************************** 245 246 // endregion ************************** interface.gotpl *************************** 247 248 // region **************************** object.gotpl **************************** 249 250 var overlappingFieldsImplementors = []string{"OverlappingFields"} 251 252 func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.SelectionSet, obj *OverlappingFields) graphql.Marshaler { 253 fields := graphql.CollectFields(ec.OperationContext, sel, overlappingFieldsImplementors) 254 out := graphql.NewFieldSet(fields) 255 var invalids uint32 256 for i, field := range fields { 257 switch field.Name { 258 case "__typename": 259 out.Values[i] = graphql.MarshalString("OverlappingFields") 260 case "oneFoo": 261 262 out.Values[i] = ec._OverlappingFields_oneFoo(ctx, field, obj) 263 264 if out.Values[i] == graphql.Null { 265 atomic.AddUint32(&invalids, 1) 266 } 267 case "twoFoo": 268 269 out.Values[i] = ec._OverlappingFields_twoFoo(ctx, field, obj) 270 271 if out.Values[i] == graphql.Null { 272 atomic.AddUint32(&invalids, 1) 273 } 274 case "oldFoo": 275 field := field 276 277 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 278 defer func() { 279 if r := recover(); r != nil { 280 ec.Error(ctx, ec.Recover(ctx, r)) 281 } 282 }() 283 res = ec._OverlappingFields_oldFoo(ctx, field, obj) 284 if res == graphql.Null { 285 atomic.AddUint32(&invalids, 1) 286 } 287 return res 288 } 289 290 out.Concurrently(i, func() graphql.Marshaler { 291 return innerFunc(ctx) 292 293 }) 294 case "newFoo": 295 296 out.Values[i] = ec._OverlappingFields_newFoo(ctx, field, obj) 297 298 if out.Values[i] == graphql.Null { 299 atomic.AddUint32(&invalids, 1) 300 } 301 case "new_foo": 302 303 out.Values[i] = ec._OverlappingFields_new_foo(ctx, field, obj) 304 305 if out.Values[i] == graphql.Null { 306 atomic.AddUint32(&invalids, 1) 307 } 308 default: 309 panic("unknown field " + strconv.Quote(field.Name)) 310 } 311 } 312 out.Dispatch() 313 if invalids > 0 { 314 return graphql.Null 315 } 316 return out 317 } 318 319 // endregion **************************** object.gotpl **************************** 320 321 // region ***************************** type.gotpl ***************************** 322 323 func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler { 324 if v == nil { 325 return graphql.Null 326 } 327 return ec._OverlappingFields(ctx, sel, v) 328 } 329 330 // endregion ***************************** type.gotpl *****************************