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