github.com/99designs/gqlgen@v0.17.45/codegen/testserver/followschema/variadic.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 "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 func (ec *executionContext) field_VariadicModel_value_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { 22 var err error 23 args := map[string]interface{}{} 24 var arg0 int 25 if tmp, ok := rawArgs["rank"]; ok { 26 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("rank")) 27 arg0, err = ec.unmarshalNInt2int(ctx, tmp) 28 if err != nil { 29 return nil, err 30 } 31 } 32 args["rank"] = arg0 33 return args, nil 34 } 35 36 // endregion ***************************** args.gotpl ***************************** 37 38 // region ************************** directives.gotpl ************************** 39 40 // endregion ************************** directives.gotpl ************************** 41 42 // region **************************** field.gotpl ***************************** 43 44 func (ec *executionContext) _VariadicModel_value(ctx context.Context, field graphql.CollectedField, obj *VariadicModel) (ret graphql.Marshaler) { 45 fc, err := ec.fieldContext_VariadicModel_value(ctx, field) 46 if err != nil { 47 return graphql.Null 48 } 49 ctx = graphql.WithFieldContext(ctx, fc) 50 defer func() { 51 if r := recover(); r != nil { 52 ec.Error(ctx, ec.Recover(ctx, r)) 53 ret = graphql.Null 54 } 55 }() 56 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 57 ctx = rctx // use context from middleware stack in children 58 return obj.Value(ctx, fc.Args["rank"].(int)) 59 }) 60 61 if resTmp == nil { 62 return graphql.Null 63 } 64 res := resTmp.(string) 65 fc.Result = res 66 return ec.marshalOString2string(ctx, field.Selections, res) 67 } 68 69 func (ec *executionContext) fieldContext_VariadicModel_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 70 fc = &graphql.FieldContext{ 71 Object: "VariadicModel", 72 Field: field, 73 IsMethod: true, 74 IsResolver: false, 75 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 76 return nil, errors.New("field of type String does not have child fields") 77 }, 78 } 79 defer func() { 80 if r := recover(); r != nil { 81 err = ec.Recover(ctx, r) 82 ec.Error(ctx, err) 83 } 84 }() 85 ctx = graphql.WithFieldContext(ctx, fc) 86 if fc.Args, err = ec.field_VariadicModel_value_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { 87 ec.Error(ctx, err) 88 return fc, err 89 } 90 return fc, nil 91 } 92 93 // endregion **************************** field.gotpl ***************************** 94 95 // region **************************** input.gotpl ***************************** 96 97 // endregion **************************** input.gotpl ***************************** 98 99 // region ************************** interface.gotpl *************************** 100 101 // endregion ************************** interface.gotpl *************************** 102 103 // region **************************** object.gotpl **************************** 104 105 var variadicModelImplementors = []string{"VariadicModel"} 106 107 func (ec *executionContext) _VariadicModel(ctx context.Context, sel ast.SelectionSet, obj *VariadicModel) graphql.Marshaler { 108 fields := graphql.CollectFields(ec.OperationContext, sel, variadicModelImplementors) 109 110 out := graphql.NewFieldSet(fields) 111 deferred := make(map[string]*graphql.FieldSet) 112 for i, field := range fields { 113 switch field.Name { 114 case "__typename": 115 out.Values[i] = graphql.MarshalString("VariadicModel") 116 case "value": 117 field := field 118 119 innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { 120 defer func() { 121 if r := recover(); r != nil { 122 ec.Error(ctx, ec.Recover(ctx, r)) 123 } 124 }() 125 res = ec._VariadicModel_value(ctx, field, obj) 126 return res 127 } 128 129 if field.Deferrable != nil { 130 dfs, ok := deferred[field.Deferrable.Label] 131 di := 0 132 if ok { 133 dfs.AddField(field) 134 di = len(dfs.Values) - 1 135 } else { 136 dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) 137 deferred[field.Deferrable.Label] = dfs 138 } 139 dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { 140 return innerFunc(ctx, dfs) 141 }) 142 143 // don't run the out.Concurrently() call below 144 out.Values[i] = graphql.Null 145 continue 146 } 147 148 out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) 149 default: 150 panic("unknown field " + strconv.Quote(field.Name)) 151 } 152 } 153 out.Dispatch(ctx) 154 if out.Invalids > 0 { 155 return graphql.Null 156 } 157 158 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 159 160 for label, dfs := range deferred { 161 ec.processDeferredGroup(graphql.DeferredGroup{ 162 Label: label, 163 Path: graphql.GetPath(ctx), 164 FieldSet: dfs, 165 Context: ctx, 166 }) 167 } 168 169 return out 170 } 171 172 // endregion **************************** object.gotpl **************************** 173 174 // region ***************************** type.gotpl ***************************** 175 176 func (ec *executionContext) marshalOVariadicModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVariadicModel(ctx context.Context, sel ast.SelectionSet, v *VariadicModel) graphql.Marshaler { 177 if v == nil { 178 return graphql.Null 179 } 180 return ec._VariadicModel(ctx, sel, v) 181 } 182 183 // endregion ***************************** type.gotpl *****************************