github.com/luciferinlove/gqlgen@v0.17.16-bzc.1/codegen/testserver/followschema/loops.generated.go (about)

     1  // Code generated by github.com/luciferinlove/gqlgen, DO NOT EDIT.
     2  
     3  package followschema
     4  
     5  import (
     6  	"context"
     7  	"fmt"
     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) _LoopA_b(ctx context.Context, field graphql.CollectedField, obj *LoopA) (ret graphql.Marshaler) {
    29  	fc, err := ec.fieldContext_LoopA_b(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.B, nil
    43  	})
    44  
    45  	if resTmp == nil {
    46  		if !graphql.HasFieldError(ctx, fc) {
    47  			ec.Errorf(ctx, "must not be null")
    48  		}
    49  		return graphql.Null
    50  	}
    51  	res := resTmp.(*LoopB)
    52  	fc.Result = res
    53  	return ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx, field.Selections, res)
    54  }
    55  
    56  func (ec *executionContext) fieldContext_LoopA_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
    57  	fc = &graphql.FieldContext{
    58  		Object:     "LoopA",
    59  		Field:      field,
    60  		IsMethod:   false,
    61  		IsResolver: false,
    62  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
    63  			switch field.Name {
    64  			case "a":
    65  				return ec.fieldContext_LoopB_a(ctx, field)
    66  			}
    67  			return nil, fmt.Errorf("no field named %q was found under type LoopB", field.Name)
    68  		},
    69  	}
    70  	return fc, nil
    71  }
    72  
    73  func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) {
    74  	fc, err := ec.fieldContext_LoopB_a(ctx, field)
    75  	if err != nil {
    76  		return graphql.Null
    77  	}
    78  	ctx = graphql.WithFieldContext(ctx, fc)
    79  	defer func() {
    80  		if r := recover(); r != nil {
    81  			ec.Error(ctx, ec.Recover(ctx, r))
    82  			ret = graphql.Null
    83  		}
    84  	}()
    85  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    86  		ctx = rctx // use context from middleware stack in children
    87  		return obj.A, nil
    88  	})
    89  
    90  	if resTmp == nil {
    91  		if !graphql.HasFieldError(ctx, fc) {
    92  			ec.Errorf(ctx, "must not be null")
    93  		}
    94  		return graphql.Null
    95  	}
    96  	res := resTmp.(*LoopA)
    97  	fc.Result = res
    98  	return ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx, field.Selections, res)
    99  }
   100  
   101  func (ec *executionContext) fieldContext_LoopB_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   102  	fc = &graphql.FieldContext{
   103  		Object:     "LoopB",
   104  		Field:      field,
   105  		IsMethod:   false,
   106  		IsResolver: false,
   107  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   108  			switch field.Name {
   109  			case "b":
   110  				return ec.fieldContext_LoopA_b(ctx, field)
   111  			}
   112  			return nil, fmt.Errorf("no field named %q was found under type LoopA", field.Name)
   113  		},
   114  	}
   115  	return fc, nil
   116  }
   117  
   118  // endregion **************************** field.gotpl *****************************
   119  
   120  // region    **************************** input.gotpl *****************************
   121  
   122  // endregion **************************** input.gotpl *****************************
   123  
   124  // region    ************************** interface.gotpl ***************************
   125  
   126  // endregion ************************** interface.gotpl ***************************
   127  
   128  // region    **************************** object.gotpl ****************************
   129  
   130  var loopAImplementors = []string{"LoopA"}
   131  
   132  func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, obj *LoopA) graphql.Marshaler {
   133  	fields := graphql.CollectFields(ec.OperationContext, sel, loopAImplementors)
   134  	out := graphql.NewFieldSet(fields)
   135  	var invalids uint32
   136  	for i, field := range fields {
   137  		switch field.Name {
   138  		case "__typename":
   139  			out.Values[i] = graphql.MarshalString("LoopA")
   140  		case "b":
   141  
   142  			out.Values[i] = ec._LoopA_b(ctx, field, obj)
   143  
   144  			if out.Values[i] == graphql.Null {
   145  				invalids++
   146  			}
   147  		default:
   148  			panic("unknown field " + strconv.Quote(field.Name))
   149  		}
   150  	}
   151  	out.Dispatch()
   152  	if invalids > 0 {
   153  		return graphql.Null
   154  	}
   155  	return out
   156  }
   157  
   158  var loopBImplementors = []string{"LoopB"}
   159  
   160  func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, obj *LoopB) graphql.Marshaler {
   161  	fields := graphql.CollectFields(ec.OperationContext, sel, loopBImplementors)
   162  	out := graphql.NewFieldSet(fields)
   163  	var invalids uint32
   164  	for i, field := range fields {
   165  		switch field.Name {
   166  		case "__typename":
   167  			out.Values[i] = graphql.MarshalString("LoopB")
   168  		case "a":
   169  
   170  			out.Values[i] = ec._LoopB_a(ctx, field, obj)
   171  
   172  			if out.Values[i] == graphql.Null {
   173  				invalids++
   174  			}
   175  		default:
   176  			panic("unknown field " + strconv.Quote(field.Name))
   177  		}
   178  	}
   179  	out.Dispatch()
   180  	if invalids > 0 {
   181  		return graphql.Null
   182  	}
   183  	return out
   184  }
   185  
   186  // endregion **************************** object.gotpl ****************************
   187  
   188  // region    ***************************** type.gotpl *****************************
   189  
   190  func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler {
   191  	if v == nil {
   192  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   193  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   194  		}
   195  		return graphql.Null
   196  	}
   197  	return ec._LoopA(ctx, sel, v)
   198  }
   199  
   200  func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler {
   201  	if v == nil {
   202  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   203  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   204  		}
   205  		return graphql.Null
   206  	}
   207  	return ec._LoopB(ctx, sel, v)
   208  }
   209  
   210  // endregion ***************************** type.gotpl *****************************