github.com/geneva/gqlgen@v0.17.7-0.20230801155730-7b9317164836/codegen/testserver/followschema/fields_order.generated.go (about) 1 // Code generated by github.com/geneva/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "errors" 8 "strconv" 9 "sync/atomic" 10 11 "github.com/geneva/gqlgen/graphql" 12 "github.com/vektah/gqlparser/v2/ast" 13 ) 14 15 // region ************************** generated!.gotpl ************************** 16 17 type FieldsOrderInputResolver interface { 18 OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) 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) _FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField, obj *FieldsOrderPayload) (ret graphql.Marshaler) { 34 fc, err := ec.fieldContext_FieldsOrderPayload_firstFieldValue(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.FirstFieldValue, nil 48 }) 49 50 if resTmp == nil { 51 return graphql.Null 52 } 53 res := resTmp.(*string) 54 fc.Result = res 55 return ec.marshalOString2ᚖstring(ctx, field.Selections, res) 56 } 57 58 func (ec *executionContext) fieldContext_FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 59 fc = &graphql.FieldContext{ 60 Object: "FieldsOrderPayload", 61 Field: field, 62 IsMethod: false, 63 IsResolver: false, 64 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 65 return nil, errors.New("field of type String does not have child fields") 66 }, 67 } 68 return fc, nil 69 } 70 71 // endregion **************************** field.gotpl ***************************** 72 73 // region **************************** input.gotpl ***************************** 74 75 func (ec *executionContext) unmarshalInputFieldsOrderInput(ctx context.Context, obj interface{}) (FieldsOrderInput, error) { 76 var it FieldsOrderInput 77 asMap := map[string]interface{}{} 78 for k, v := range obj.(map[string]interface{}) { 79 asMap[k] = v 80 } 81 82 fieldsInOrder := [...]string{"firstField", "overrideFirstField"} 83 for _, k := range fieldsInOrder { 84 v, ok := asMap[k] 85 if !ok { 86 continue 87 } 88 switch k { 89 case "firstField": 90 var err error 91 92 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstField")) 93 data, err := ec.unmarshalOString2ᚖstring(ctx, v) 94 if err != nil { 95 return it, err 96 } 97 it.FirstField = data 98 case "overrideFirstField": 99 var err error 100 101 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("overrideFirstField")) 102 data, err := ec.unmarshalOString2ᚖstring(ctx, v) 103 if err != nil { 104 return it, err 105 } 106 if err = ec.resolvers.FieldsOrderInput().OverrideFirstField(ctx, &it, data); err != nil { 107 return it, err 108 } 109 } 110 } 111 112 return it, nil 113 } 114 115 // endregion **************************** input.gotpl ***************************** 116 117 // region ************************** interface.gotpl *************************** 118 119 // endregion ************************** interface.gotpl *************************** 120 121 // region **************************** object.gotpl **************************** 122 123 var fieldsOrderPayloadImplementors = []string{"FieldsOrderPayload"} 124 125 func (ec *executionContext) _FieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, obj *FieldsOrderPayload) graphql.Marshaler { 126 fields := graphql.CollectFields(ec.OperationContext, sel, fieldsOrderPayloadImplementors) 127 128 out := graphql.NewFieldSet(fields) 129 deferred := make(map[string]*graphql.FieldSet) 130 for i, field := range fields { 131 switch field.Name { 132 case "__typename": 133 out.Values[i] = graphql.MarshalString("FieldsOrderPayload") 134 case "firstFieldValue": 135 out.Values[i] = ec._FieldsOrderPayload_firstFieldValue(ctx, field, obj) 136 default: 137 panic("unknown field " + strconv.Quote(field.Name)) 138 } 139 } 140 out.Dispatch(ctx) 141 if out.Invalids > 0 { 142 return graphql.Null 143 } 144 145 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 146 147 for label, dfs := range deferred { 148 ec.processDeferredGroup(graphql.DeferredGroup{ 149 Label: label, 150 Path: graphql.GetPath(ctx), 151 FieldSet: dfs, 152 Context: ctx, 153 }) 154 } 155 156 return out 157 } 158 159 // endregion **************************** object.gotpl **************************** 160 161 // region ***************************** type.gotpl ***************************** 162 163 func (ec *executionContext) unmarshalNFieldsOrderInput2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderInput(ctx context.Context, v interface{}) (FieldsOrderInput, error) { 164 res, err := ec.unmarshalInputFieldsOrderInput(ctx, v) 165 return res, graphql.ErrorOnPath(ctx, err) 166 } 167 168 func (ec *executionContext) marshalNFieldsOrderPayload2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v FieldsOrderPayload) graphql.Marshaler { 169 return ec._FieldsOrderPayload(ctx, sel, &v) 170 } 171 172 func (ec *executionContext) marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v *FieldsOrderPayload) graphql.Marshaler { 173 if v == nil { 174 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 175 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 176 } 177 return graphql.Null 178 } 179 return ec._FieldsOrderPayload(ctx, sel, v) 180 } 181 182 // endregion ***************************** type.gotpl *****************************