github.com/luciferinlove/gqlgen@v0.17.16-bzc.1/codegen/testserver/followschema/fields_order.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  type FieldsOrderInputResolver interface {
    17  	OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error
    18  }
    19  
    20  // endregion ************************** generated!.gotpl **************************
    21  
    22  // region    ***************************** args.gotpl *****************************
    23  
    24  // endregion ***************************** args.gotpl *****************************
    25  
    26  // region    ************************** directives.gotpl **************************
    27  
    28  // endregion ************************** directives.gotpl **************************
    29  
    30  // region    **************************** field.gotpl *****************************
    31  
    32  func (ec *executionContext) _FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField, obj *FieldsOrderPayload) (ret graphql.Marshaler) {
    33  	fc, err := ec.fieldContext_FieldsOrderPayload_firstFieldValue(ctx, field)
    34  	if err != nil {
    35  		return graphql.Null
    36  	}
    37  	ctx = graphql.WithFieldContext(ctx, fc)
    38  	defer func() {
    39  		if r := recover(); r != nil {
    40  			ec.Error(ctx, ec.Recover(ctx, r))
    41  			ret = graphql.Null
    42  		}
    43  	}()
    44  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    45  		ctx = rctx // use context from middleware stack in children
    46  		return obj.FirstFieldValue, nil
    47  	})
    48  
    49  	if resTmp == nil {
    50  		return graphql.Null
    51  	}
    52  	res := resTmp.(*string)
    53  	fc.Result = res
    54  	return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
    55  }
    56  
    57  func (ec *executionContext) fieldContext_FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
    58  	fc = &graphql.FieldContext{
    59  		Object:     "FieldsOrderPayload",
    60  		Field:      field,
    61  		IsMethod:   false,
    62  		IsResolver: false,
    63  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
    64  			return nil, errors.New("field of type String does not have child fields")
    65  		},
    66  	}
    67  	return fc, nil
    68  }
    69  
    70  // endregion **************************** field.gotpl *****************************
    71  
    72  // region    **************************** input.gotpl *****************************
    73  
    74  func (ec *executionContext) unmarshalInputFieldsOrderInput(ctx context.Context, obj interface{}) (FieldsOrderInput, error) {
    75  	var it FieldsOrderInput
    76  	asMap := map[string]interface{}{}
    77  	for k, v := range obj.(map[string]interface{}) {
    78  		asMap[k] = v
    79  	}
    80  
    81  	fieldsInOrder := [...]string{"firstField", "overrideFirstField"}
    82  	for _, k := range fieldsInOrder {
    83  		v, ok := asMap[k]
    84  		if !ok {
    85  			continue
    86  		}
    87  		switch k {
    88  		case "firstField":
    89  			var err error
    90  
    91  			ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstField"))
    92  			it.FirstField, err = ec.unmarshalOString2ᚖstring(ctx, v)
    93  			if err != nil {
    94  				return it, err
    95  			}
    96  		case "overrideFirstField":
    97  			var err error
    98  
    99  			ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("overrideFirstField"))
   100  			data, err := ec.unmarshalOString2ᚖstring(ctx, v)
   101  			if err != nil {
   102  				return it, err
   103  			}
   104  			if err = ec.resolvers.FieldsOrderInput().OverrideFirstField(ctx, &it, data); err != nil {
   105  				return it, err
   106  			}
   107  		}
   108  	}
   109  
   110  	return it, nil
   111  }
   112  
   113  // endregion **************************** input.gotpl *****************************
   114  
   115  // region    ************************** interface.gotpl ***************************
   116  
   117  // endregion ************************** interface.gotpl ***************************
   118  
   119  // region    **************************** object.gotpl ****************************
   120  
   121  var fieldsOrderPayloadImplementors = []string{"FieldsOrderPayload"}
   122  
   123  func (ec *executionContext) _FieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, obj *FieldsOrderPayload) graphql.Marshaler {
   124  	fields := graphql.CollectFields(ec.OperationContext, sel, fieldsOrderPayloadImplementors)
   125  	out := graphql.NewFieldSet(fields)
   126  	var invalids uint32
   127  	for i, field := range fields {
   128  		switch field.Name {
   129  		case "__typename":
   130  			out.Values[i] = graphql.MarshalString("FieldsOrderPayload")
   131  		case "firstFieldValue":
   132  
   133  			out.Values[i] = ec._FieldsOrderPayload_firstFieldValue(ctx, field, obj)
   134  
   135  		default:
   136  			panic("unknown field " + strconv.Quote(field.Name))
   137  		}
   138  	}
   139  	out.Dispatch()
   140  	if invalids > 0 {
   141  		return graphql.Null
   142  	}
   143  	return out
   144  }
   145  
   146  // endregion **************************** object.gotpl ****************************
   147  
   148  // region    ***************************** type.gotpl *****************************
   149  
   150  func (ec *executionContext) unmarshalNFieldsOrderInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderInput(ctx context.Context, v interface{}) (FieldsOrderInput, error) {
   151  	res, err := ec.unmarshalInputFieldsOrderInput(ctx, v)
   152  	return res, graphql.ErrorOnPath(ctx, err)
   153  }
   154  
   155  func (ec *executionContext) marshalNFieldsOrderPayload2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v FieldsOrderPayload) graphql.Marshaler {
   156  	return ec._FieldsOrderPayload(ctx, sel, &v)
   157  }
   158  
   159  func (ec *executionContext) marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v *FieldsOrderPayload) graphql.Marshaler {
   160  	if v == nil {
   161  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   162  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   163  		}
   164  		return graphql.Null
   165  	}
   166  	return ec._FieldsOrderPayload(ctx, sel, v)
   167  }
   168  
   169  // endregion ***************************** type.gotpl *****************************