github.com/99designs/gqlgen@v0.17.45/codegen/testserver/followschema/fields_order.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 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 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstField")) 91 data, err := ec.unmarshalOString2ᚖstring(ctx, v) 92 if err != nil { 93 return it, err 94 } 95 it.FirstField = data 96 case "overrideFirstField": 97 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("overrideFirstField")) 98 data, err := ec.unmarshalOString2ᚖstring(ctx, v) 99 if err != nil { 100 return it, err 101 } 102 if err = ec.resolvers.FieldsOrderInput().OverrideFirstField(ctx, &it, data); err != nil { 103 return it, err 104 } 105 } 106 } 107 108 return it, nil 109 } 110 111 // endregion **************************** input.gotpl ***************************** 112 113 // region ************************** interface.gotpl *************************** 114 115 // endregion ************************** interface.gotpl *************************** 116 117 // region **************************** object.gotpl **************************** 118 119 var fieldsOrderPayloadImplementors = []string{"FieldsOrderPayload"} 120 121 func (ec *executionContext) _FieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, obj *FieldsOrderPayload) graphql.Marshaler { 122 fields := graphql.CollectFields(ec.OperationContext, sel, fieldsOrderPayloadImplementors) 123 124 out := graphql.NewFieldSet(fields) 125 deferred := make(map[string]*graphql.FieldSet) 126 for i, field := range fields { 127 switch field.Name { 128 case "__typename": 129 out.Values[i] = graphql.MarshalString("FieldsOrderPayload") 130 case "firstFieldValue": 131 out.Values[i] = ec._FieldsOrderPayload_firstFieldValue(ctx, field, obj) 132 default: 133 panic("unknown field " + strconv.Quote(field.Name)) 134 } 135 } 136 out.Dispatch(ctx) 137 if out.Invalids > 0 { 138 return graphql.Null 139 } 140 141 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 142 143 for label, dfs := range deferred { 144 ec.processDeferredGroup(graphql.DeferredGroup{ 145 Label: label, 146 Path: graphql.GetPath(ctx), 147 FieldSet: dfs, 148 Context: ctx, 149 }) 150 } 151 152 return out 153 } 154 155 // endregion **************************** object.gotpl **************************** 156 157 // region ***************************** type.gotpl ***************************** 158 159 func (ec *executionContext) unmarshalNFieldsOrderInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderInput(ctx context.Context, v interface{}) (FieldsOrderInput, error) { 160 res, err := ec.unmarshalInputFieldsOrderInput(ctx, v) 161 return res, graphql.ErrorOnPath(ctx, err) 162 } 163 164 func (ec *executionContext) marshalNFieldsOrderPayload2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v FieldsOrderPayload) graphql.Marshaler { 165 return ec._FieldsOrderPayload(ctx, sel, &v) 166 } 167 168 func (ec *executionContext) marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v *FieldsOrderPayload) graphql.Marshaler { 169 if v == nil { 170 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 171 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 172 } 173 return graphql.Null 174 } 175 return ec._FieldsOrderPayload(ctx, sel, v) 176 } 177 178 // endregion ***************************** type.gotpl *****************************