github.com/99designs/gqlgen@v0.17.45/codegen/testserver/followschema/loops.generated.go (about) 1 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "fmt" 8 "strconv" 9 "sync/atomic" 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) _LoopA_b(ctx context.Context, field graphql.CollectedField, obj *LoopA) (ret graphql.Marshaler) { 30 fc, err := ec.fieldContext_LoopA_b(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 return obj.B, nil 44 }) 45 46 if resTmp == nil { 47 if !graphql.HasFieldError(ctx, fc) { 48 ec.Errorf(ctx, "must not be null") 49 } 50 return graphql.Null 51 } 52 res := resTmp.(*LoopB) 53 fc.Result = res 54 return ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx, field.Selections, res) 55 } 56 57 func (ec *executionContext) fieldContext_LoopA_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 58 fc = &graphql.FieldContext{ 59 Object: "LoopA", 60 Field: field, 61 IsMethod: false, 62 IsResolver: false, 63 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 64 switch field.Name { 65 case "a": 66 return ec.fieldContext_LoopB_a(ctx, field) 67 } 68 return nil, fmt.Errorf("no field named %q was found under type LoopB", field.Name) 69 }, 70 } 71 return fc, nil 72 } 73 74 func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) { 75 fc, err := ec.fieldContext_LoopB_a(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.A, 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.(*LoopA) 98 fc.Result = res 99 return ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx, field.Selections, res) 100 } 101 102 func (ec *executionContext) fieldContext_LoopB_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 103 fc = &graphql.FieldContext{ 104 Object: "LoopB", 105 Field: field, 106 IsMethod: false, 107 IsResolver: false, 108 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 109 switch field.Name { 110 case "b": 111 return ec.fieldContext_LoopA_b(ctx, field) 112 } 113 return nil, fmt.Errorf("no field named %q was found under type LoopA", field.Name) 114 }, 115 } 116 return fc, nil 117 } 118 119 // endregion **************************** field.gotpl ***************************** 120 121 // region **************************** input.gotpl ***************************** 122 123 // endregion **************************** input.gotpl ***************************** 124 125 // region ************************** interface.gotpl *************************** 126 127 // endregion ************************** interface.gotpl *************************** 128 129 // region **************************** object.gotpl **************************** 130 131 var loopAImplementors = []string{"LoopA"} 132 133 func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, obj *LoopA) graphql.Marshaler { 134 fields := graphql.CollectFields(ec.OperationContext, sel, loopAImplementors) 135 136 out := graphql.NewFieldSet(fields) 137 deferred := make(map[string]*graphql.FieldSet) 138 for i, field := range fields { 139 switch field.Name { 140 case "__typename": 141 out.Values[i] = graphql.MarshalString("LoopA") 142 case "b": 143 out.Values[i] = ec._LoopA_b(ctx, field, obj) 144 if out.Values[i] == graphql.Null { 145 out.Invalids++ 146 } 147 default: 148 panic("unknown field " + strconv.Quote(field.Name)) 149 } 150 } 151 out.Dispatch(ctx) 152 if out.Invalids > 0 { 153 return graphql.Null 154 } 155 156 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 157 158 for label, dfs := range deferred { 159 ec.processDeferredGroup(graphql.DeferredGroup{ 160 Label: label, 161 Path: graphql.GetPath(ctx), 162 FieldSet: dfs, 163 Context: ctx, 164 }) 165 } 166 167 return out 168 } 169 170 var loopBImplementors = []string{"LoopB"} 171 172 func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, obj *LoopB) graphql.Marshaler { 173 fields := graphql.CollectFields(ec.OperationContext, sel, loopBImplementors) 174 175 out := graphql.NewFieldSet(fields) 176 deferred := make(map[string]*graphql.FieldSet) 177 for i, field := range fields { 178 switch field.Name { 179 case "__typename": 180 out.Values[i] = graphql.MarshalString("LoopB") 181 case "a": 182 out.Values[i] = ec._LoopB_a(ctx, field, obj) 183 if out.Values[i] == graphql.Null { 184 out.Invalids++ 185 } 186 default: 187 panic("unknown field " + strconv.Quote(field.Name)) 188 } 189 } 190 out.Dispatch(ctx) 191 if out.Invalids > 0 { 192 return graphql.Null 193 } 194 195 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 196 197 for label, dfs := range deferred { 198 ec.processDeferredGroup(graphql.DeferredGroup{ 199 Label: label, 200 Path: graphql.GetPath(ctx), 201 FieldSet: dfs, 202 Context: ctx, 203 }) 204 } 205 206 return out 207 } 208 209 // endregion **************************** object.gotpl **************************** 210 211 // region ***************************** type.gotpl ***************************** 212 213 func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler { 214 if v == nil { 215 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 216 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 217 } 218 return graphql.Null 219 } 220 return ec._LoopA(ctx, sel, v) 221 } 222 223 func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler { 224 if v == nil { 225 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 226 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 227 } 228 return graphql.Null 229 } 230 return ec._LoopB(ctx, sel, v) 231 } 232 233 // endregion ***************************** type.gotpl *****************************