github.com/operandinc/gqlgen@v0.16.1/codegen/testserver/followschema/scalar_default.generated.go (about) 1 // Code generated by github.com/operandinc/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "strconv" 8 9 "github.com/operandinc/gqlgen/graphql" 10 "github.com/vektah/gqlparser/v2/ast" 11 ) 12 13 // region ************************** generated!.gotpl ************************** 14 15 // endregion ************************** generated!.gotpl ************************** 16 17 // region ***************************** args.gotpl ***************************** 18 19 // endregion ***************************** args.gotpl ***************************** 20 21 // region ************************** directives.gotpl ************************** 22 23 // endregion ************************** directives.gotpl ************************** 24 25 // region **************************** field.gotpl ***************************** 26 27 func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField, obj *EmbeddedDefaultScalar) (ret graphql.Marshaler) { 28 defer func() { 29 if r := recover(); r != nil { 30 ec.Error(ctx, ec.Recover(ctx, r)) 31 ret = graphql.Null 32 } 33 }() 34 fc := &graphql.FieldContext{ 35 Object: "EmbeddedDefaultScalar", 36 Field: field, 37 Args: nil, 38 IsMethod: false, 39 IsResolver: false, 40 } 41 42 ctx = graphql.WithFieldContext(ctx, fc) 43 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 44 ctx = rctx // use context from middleware stack in children 45 return obj.Value, nil 46 }) 47 48 if resTmp == nil { 49 return graphql.Null 50 } 51 res := resTmp.(*string) 52 fc.Result = res 53 return ec.marshalODefaultScalarImplementation2ᚖstring(ctx, field.Selections, res) 54 } 55 56 // endregion **************************** field.gotpl ***************************** 57 58 // region **************************** input.gotpl ***************************** 59 60 // endregion **************************** input.gotpl ***************************** 61 62 // region ************************** interface.gotpl *************************** 63 64 // endregion ************************** interface.gotpl *************************** 65 66 // region **************************** object.gotpl **************************** 67 68 var embeddedDefaultScalarImplementors = []string{"EmbeddedDefaultScalar"} 69 70 func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedDefaultScalar) graphql.Marshaler { 71 fields := graphql.CollectFields(ec.OperationContext, sel, embeddedDefaultScalarImplementors) 72 out := graphql.NewFieldSet(fields) 73 var invalids uint32 74 for i, field := range fields { 75 switch field.Name { 76 case "__typename": 77 out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar") 78 case "value": 79 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 80 return ec._EmbeddedDefaultScalar_value(ctx, field, obj) 81 } 82 83 out.Values[i] = innerFunc(ctx) 84 85 default: 86 panic("unknown field " + strconv.Quote(field.Name)) 87 } 88 } 89 out.Dispatch() 90 if invalids > 0 { 91 return graphql.Null 92 } 93 return out 94 } 95 96 // endregion **************************** object.gotpl **************************** 97 98 // region ***************************** type.gotpl ***************************** 99 100 func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx context.Context, v interface{}) (string, error) { 101 res, err := graphql.UnmarshalString(v) 102 return res, graphql.ErrorOnPath(ctx, err) 103 } 104 105 func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 106 res := graphql.MarshalString(v) 107 if res == graphql.Null { 108 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 109 ec.Errorf(ctx, "must not be null") 110 } 111 } 112 return res 113 } 114 115 func (ec *executionContext) unmarshalODefaultScalarImplementation2ᚖstring(ctx context.Context, v interface{}) (*string, error) { 116 if v == nil { 117 return nil, nil 118 } 119 res, err := graphql.UnmarshalString(v) 120 return &res, graphql.ErrorOnPath(ctx, err) 121 } 122 123 func (ec *executionContext) marshalODefaultScalarImplementation2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { 124 if v == nil { 125 return graphql.Null 126 } 127 res := graphql.MarshalString(*v) 128 return res 129 } 130 131 // endregion ***************************** type.gotpl *****************************