...

Source file src/github.com/99designs/gqlgen/codegen/testserver/followschema/ptr_to_any.generated.go

Documentation: github.com/99designs/gqlgen/codegen/testserver/followschema

     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) _PtrToAnyContainer_ptrToAny(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) {
    30  	fc, err := ec.fieldContext_PtrToAnyContainer_ptrToAny(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.PtrToAny, nil
    44  	})
    45  
    46  	if resTmp == nil {
    47  		return graphql.Null
    48  	}
    49  	res := resTmp.(*any)
    50  	fc.Result = res
    51  	return ec.marshalOAny2ᚖinterface(ctx, field.Selections, res)
    52  }
    53  
    54  func (ec *executionContext) fieldContext_PtrToAnyContainer_ptrToAny(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
    55  	fc = &graphql.FieldContext{
    56  		Object:     "PtrToAnyContainer",
    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 Any does not have child fields")
    62  		},
    63  	}
    64  	return fc, nil
    65  }
    66  
    67  func (ec *executionContext) _PtrToAnyContainer_binding(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) {
    68  	fc, err := ec.fieldContext_PtrToAnyContainer_binding(ctx, field)
    69  	if err != nil {
    70  		return graphql.Null
    71  	}
    72  	ctx = graphql.WithFieldContext(ctx, fc)
    73  	defer func() {
    74  		if r := recover(); r != nil {
    75  			ec.Error(ctx, ec.Recover(ctx, r))
    76  			ret = graphql.Null
    77  		}
    78  	}()
    79  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    80  		ctx = rctx // use context from middleware stack in children
    81  		return obj.Binding(), nil
    82  	})
    83  
    84  	if resTmp == nil {
    85  		return graphql.Null
    86  	}
    87  	res := resTmp.(*any)
    88  	fc.Result = res
    89  	return ec.marshalOAny2ᚖinterface(ctx, field.Selections, res)
    90  }
    91  
    92  func (ec *executionContext) fieldContext_PtrToAnyContainer_binding(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
    93  	fc = &graphql.FieldContext{
    94  		Object:     "PtrToAnyContainer",
    95  		Field:      field,
    96  		IsMethod:   true,
    97  		IsResolver: false,
    98  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
    99  			return nil, errors.New("field of type Any does not have child fields")
   100  		},
   101  	}
   102  	return fc, nil
   103  }
   104  
   105  // endregion **************************** field.gotpl *****************************
   106  
   107  // region    **************************** input.gotpl *****************************
   108  
   109  // endregion **************************** input.gotpl *****************************
   110  
   111  // region    ************************** interface.gotpl ***************************
   112  
   113  // endregion ************************** interface.gotpl ***************************
   114  
   115  // region    **************************** object.gotpl ****************************
   116  
   117  var ptrToAnyContainerImplementors = []string{"PtrToAnyContainer"}
   118  
   119  func (ec *executionContext) _PtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToAnyContainer) graphql.Marshaler {
   120  	fields := graphql.CollectFields(ec.OperationContext, sel, ptrToAnyContainerImplementors)
   121  
   122  	out := graphql.NewFieldSet(fields)
   123  	deferred := make(map[string]*graphql.FieldSet)
   124  	for i, field := range fields {
   125  		switch field.Name {
   126  		case "__typename":
   127  			out.Values[i] = graphql.MarshalString("PtrToAnyContainer")
   128  		case "ptrToAny":
   129  			out.Values[i] = ec._PtrToAnyContainer_ptrToAny(ctx, field, obj)
   130  		case "binding":
   131  			out.Values[i] = ec._PtrToAnyContainer_binding(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) marshalNPtrToAnyContainer2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v PtrToAnyContainer) graphql.Marshaler {
   160  	return ec._PtrToAnyContainer(ctx, sel, &v)
   161  }
   162  
   163  func (ec *executionContext) marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToAnyContainer) graphql.Marshaler {
   164  	if v == nil {
   165  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   166  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   167  		}
   168  		return graphql.Null
   169  	}
   170  	return ec._PtrToAnyContainer(ctx, sel, v)
   171  }
   172  
   173  func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v interface{}) (any, error) {
   174  	if v == nil {
   175  		return nil, nil
   176  	}
   177  	res, err := graphql.UnmarshalAny(v)
   178  	return res, graphql.ErrorOnPath(ctx, err)
   179  }
   180  
   181  func (ec *executionContext) marshalOAny2interface(ctx context.Context, sel ast.SelectionSet, v any) graphql.Marshaler {
   182  	if v == nil {
   183  		return graphql.Null
   184  	}
   185  	res := graphql.MarshalAny(v)
   186  	return res
   187  }
   188  
   189  func (ec *executionContext) unmarshalOAny2ᚖinterface(ctx context.Context, v interface{}) (*any, error) {
   190  	if v == nil {
   191  		return nil, nil
   192  	}
   193  	res, err := ec.unmarshalOAny2interface(ctx, v)
   194  	return &res, graphql.ErrorOnPath(ctx, err)
   195  }
   196  
   197  func (ec *executionContext) marshalOAny2ᚖinterface(ctx context.Context, sel ast.SelectionSet, v *any) graphql.Marshaler {
   198  	return ec.marshalOAny2interface(ctx, sel, *v)
   199  }
   200  
   201  // endregion ***************************** type.gotpl *****************************
   202  

View as plain text