github.com/operandinc/gqlgen@v0.16.1/codegen/testserver/followschema/loops.generated.go (about)

     1  // Code generated by github.com/operandinc/gqlgen, DO NOT EDIT.
     2  
     3  package followschema
     4  
     5  import (
     6  	"context"
     7  	"strconv"
     8  
     9  	"github.com/operandinc/gqlgen/graphql"
    10  	"github.com/vektah/gqlparser/v2/ast"
    11  )
    12  
    13  // region    ************************** generated!.gotpl **************************
    14  
    15  // endregion ************************** generated!.gotpl **************************
    16  
    17  // region    ***************************** args.gotpl *****************************
    18  
    19  // endregion ***************************** args.gotpl *****************************
    20  
    21  // region    ************************** directives.gotpl **************************
    22  
    23  // endregion ************************** directives.gotpl **************************
    24  
    25  // region    **************************** field.gotpl *****************************
    26  
    27  func (ec *executionContext) _LoopA_b(ctx context.Context, field graphql.CollectedField, obj *LoopA) (ret graphql.Marshaler) {
    28  	defer func() {
    29  		if r := recover(); r != nil {
    30  			ec.Error(ctx, ec.Recover(ctx, r))
    31  			ret = graphql.Null
    32  		}
    33  	}()
    34  	fc := &graphql.FieldContext{
    35  		Object:     "LoopA",
    36  		Field:      field,
    37  		Args:       nil,
    38  		IsMethod:   false,
    39  		IsResolver: false,
    40  	}
    41  
    42  	ctx = graphql.WithFieldContext(ctx, fc)
    43  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    44  		ctx = rctx // use context from middleware stack in children
    45  		return obj.B, nil
    46  	})
    47  
    48  	if resTmp == nil {
    49  		if !graphql.HasFieldError(ctx, fc) {
    50  			ec.Errorf(ctx, "must not be null")
    51  		}
    52  		return graphql.Null
    53  	}
    54  	res := resTmp.(*LoopB)
    55  	fc.Result = res
    56  	return ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx, field.Selections, res)
    57  }
    58  
    59  func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) {
    60  	defer func() {
    61  		if r := recover(); r != nil {
    62  			ec.Error(ctx, ec.Recover(ctx, r))
    63  			ret = graphql.Null
    64  		}
    65  	}()
    66  	fc := &graphql.FieldContext{
    67  		Object:     "LoopB",
    68  		Field:      field,
    69  		Args:       nil,
    70  		IsMethod:   false,
    71  		IsResolver: false,
    72  	}
    73  
    74  	ctx = graphql.WithFieldContext(ctx, fc)
    75  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    76  		ctx = rctx // use context from middleware stack in children
    77  		return obj.A, nil
    78  	})
    79  
    80  	if resTmp == nil {
    81  		if !graphql.HasFieldError(ctx, fc) {
    82  			ec.Errorf(ctx, "must not be null")
    83  		}
    84  		return graphql.Null
    85  	}
    86  	res := resTmp.(*LoopA)
    87  	fc.Result = res
    88  	return ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx, field.Selections, res)
    89  }
    90  
    91  // endregion **************************** field.gotpl *****************************
    92  
    93  // region    **************************** input.gotpl *****************************
    94  
    95  // endregion **************************** input.gotpl *****************************
    96  
    97  // region    ************************** interface.gotpl ***************************
    98  
    99  // endregion ************************** interface.gotpl ***************************
   100  
   101  // region    **************************** object.gotpl ****************************
   102  
   103  var loopAImplementors = []string{"LoopA"}
   104  
   105  func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, obj *LoopA) graphql.Marshaler {
   106  	fields := graphql.CollectFields(ec.OperationContext, sel, loopAImplementors)
   107  	out := graphql.NewFieldSet(fields)
   108  	var invalids uint32
   109  	for i, field := range fields {
   110  		switch field.Name {
   111  		case "__typename":
   112  			out.Values[i] = graphql.MarshalString("LoopA")
   113  		case "b":
   114  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   115  				return ec._LoopA_b(ctx, field, obj)
   116  			}
   117  
   118  			out.Values[i] = innerFunc(ctx)
   119  
   120  			if out.Values[i] == graphql.Null {
   121  				invalids++
   122  			}
   123  		default:
   124  			panic("unknown field " + strconv.Quote(field.Name))
   125  		}
   126  	}
   127  	out.Dispatch()
   128  	if invalids > 0 {
   129  		return graphql.Null
   130  	}
   131  	return out
   132  }
   133  
   134  var loopBImplementors = []string{"LoopB"}
   135  
   136  func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, obj *LoopB) graphql.Marshaler {
   137  	fields := graphql.CollectFields(ec.OperationContext, sel, loopBImplementors)
   138  	out := graphql.NewFieldSet(fields)
   139  	var invalids uint32
   140  	for i, field := range fields {
   141  		switch field.Name {
   142  		case "__typename":
   143  			out.Values[i] = graphql.MarshalString("LoopB")
   144  		case "a":
   145  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   146  				return ec._LoopB_a(ctx, field, obj)
   147  			}
   148  
   149  			out.Values[i] = innerFunc(ctx)
   150  
   151  			if out.Values[i] == graphql.Null {
   152  				invalids++
   153  			}
   154  		default:
   155  			panic("unknown field " + strconv.Quote(field.Name))
   156  		}
   157  	}
   158  	out.Dispatch()
   159  	if invalids > 0 {
   160  		return graphql.Null
   161  	}
   162  	return out
   163  }
   164  
   165  // endregion **************************** object.gotpl ****************************
   166  
   167  // region    ***************************** type.gotpl *****************************
   168  
   169  func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler {
   170  	if v == nil {
   171  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   172  			ec.Errorf(ctx, "must not be null")
   173  		}
   174  		return graphql.Null
   175  	}
   176  	return ec._LoopA(ctx, sel, v)
   177  }
   178  
   179  func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler {
   180  	if v == nil {
   181  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   182  			ec.Errorf(ctx, "must not be null")
   183  		}
   184  		return graphql.Null
   185  	}
   186  	return ec._LoopB(ctx, sel, v)
   187  }
   188  
   189  // endregion ***************************** type.gotpl *****************************