github.com/99designs/gqlgen@v0.17.45/codegen/testserver/followschema/scalar_default.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 // endregion ***************************** args.gotpl ***************************** 22 23 // region ************************** directives.gotpl ************************** 24 25 // endregion ************************** directives.gotpl ************************** 26 27 // region **************************** field.gotpl ***************************** 28 29 func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField, obj *EmbeddedDefaultScalar) (ret graphql.Marshaler) { 30 fc, err := ec.fieldContext_EmbeddedDefaultScalar_value(ctx, field) 31 if err != nil { 32 return graphql.Null 33 } 34 ctx = graphql.WithFieldContext(ctx, fc) 35 defer func() { 36 if r := recover(); r != nil { 37 ec.Error(ctx, ec.Recover(ctx, r)) 38 ret = graphql.Null 39 } 40 }() 41 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 42 ctx = rctx // use context from middleware stack in children 43 return obj.Value, nil 44 }) 45 46 if resTmp == nil { 47 return graphql.Null 48 } 49 res := resTmp.(*string) 50 fc.Result = res 51 return ec.marshalODefaultScalarImplementation2ᚖstring(ctx, field.Selections, res) 52 } 53 54 func (ec *executionContext) fieldContext_EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 55 fc = &graphql.FieldContext{ 56 Object: "EmbeddedDefaultScalar", 57 Field: field, 58 IsMethod: false, 59 IsResolver: false, 60 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 61 return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") 62 }, 63 } 64 return fc, nil 65 } 66 67 // endregion **************************** field.gotpl ***************************** 68 69 // region **************************** input.gotpl ***************************** 70 71 // endregion **************************** input.gotpl ***************************** 72 73 // region ************************** interface.gotpl *************************** 74 75 // endregion ************************** interface.gotpl *************************** 76 77 // region **************************** object.gotpl **************************** 78 79 var embeddedDefaultScalarImplementors = []string{"EmbeddedDefaultScalar"} 80 81 func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedDefaultScalar) graphql.Marshaler { 82 fields := graphql.CollectFields(ec.OperationContext, sel, embeddedDefaultScalarImplementors) 83 84 out := graphql.NewFieldSet(fields) 85 deferred := make(map[string]*graphql.FieldSet) 86 for i, field := range fields { 87 switch field.Name { 88 case "__typename": 89 out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar") 90 case "value": 91 out.Values[i] = ec._EmbeddedDefaultScalar_value(ctx, field, obj) 92 default: 93 panic("unknown field " + strconv.Quote(field.Name)) 94 } 95 } 96 out.Dispatch(ctx) 97 if out.Invalids > 0 { 98 return graphql.Null 99 } 100 101 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 102 103 for label, dfs := range deferred { 104 ec.processDeferredGroup(graphql.DeferredGroup{ 105 Label: label, 106 Path: graphql.GetPath(ctx), 107 FieldSet: dfs, 108 Context: ctx, 109 }) 110 } 111 112 return out 113 } 114 115 // endregion **************************** object.gotpl **************************** 116 117 // region ***************************** type.gotpl ***************************** 118 119 func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx context.Context, v interface{}) (string, error) { 120 res, err := graphql.UnmarshalString(v) 121 return res, graphql.ErrorOnPath(ctx, err) 122 } 123 124 func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { 125 res := graphql.MarshalString(v) 126 if res == graphql.Null { 127 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 128 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 129 } 130 } 131 return res 132 } 133 134 func (ec *executionContext) unmarshalODefaultScalarImplementation2ᚖstring(ctx context.Context, v interface{}) (*string, error) { 135 if v == nil { 136 return nil, nil 137 } 138 res, err := graphql.UnmarshalString(v) 139 return &res, graphql.ErrorOnPath(ctx, err) 140 } 141 142 func (ec *executionContext) marshalODefaultScalarImplementation2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { 143 if v == nil { 144 return graphql.Null 145 } 146 res := graphql.MarshalString(*v) 147 return res 148 } 149 150 // endregion ***************************** type.gotpl *****************************