...

Source file src/github.com/99designs/gqlgen/codegen/testserver/followschema/complexity.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  type OverlappingFieldsResolver interface {
    18  	OldFoo(ctx context.Context, obj *OverlappingFields) (int, error)
    19  }
    20  
    21  // endregion ************************** generated!.gotpl **************************
    22  
    23  // region    ***************************** args.gotpl *****************************
    24  
    25  // endregion ***************************** args.gotpl *****************************
    26  
    27  // region    ************************** directives.gotpl **************************
    28  
    29  // endregion ************************** directives.gotpl **************************
    30  
    31  // region    **************************** field.gotpl *****************************
    32  
    33  func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
    34  	fc, err := ec.fieldContext_OverlappingFields_oneFoo(ctx, field)
    35  	if err != nil {
    36  		return graphql.Null
    37  	}
    38  	ctx = graphql.WithFieldContext(ctx, fc)
    39  	defer func() {
    40  		if r := recover(); r != nil {
    41  			ec.Error(ctx, ec.Recover(ctx, r))
    42  			ret = graphql.Null
    43  		}
    44  	}()
    45  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    46  		ctx = rctx // use context from middleware stack in children
    47  		return obj.Foo, nil
    48  	})
    49  
    50  	if resTmp == nil {
    51  		if !graphql.HasFieldError(ctx, fc) {
    52  			ec.Errorf(ctx, "must not be null")
    53  		}
    54  		return graphql.Null
    55  	}
    56  	res := resTmp.(int)
    57  	fc.Result = res
    58  	return ec.marshalNInt2int(ctx, field.Selections, res)
    59  }
    60  
    61  func (ec *executionContext) fieldContext_OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
    62  	fc = &graphql.FieldContext{
    63  		Object:     "OverlappingFields",
    64  		Field:      field,
    65  		IsMethod:   false,
    66  		IsResolver: false,
    67  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
    68  			return nil, errors.New("field of type Int does not have child fields")
    69  		},
    70  	}
    71  	return fc, nil
    72  }
    73  
    74  func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
    75  	fc, err := ec.fieldContext_OverlappingFields_twoFoo(ctx, field)
    76  	if err != nil {
    77  		return graphql.Null
    78  	}
    79  	ctx = graphql.WithFieldContext(ctx, fc)
    80  	defer func() {
    81  		if r := recover(); r != nil {
    82  			ec.Error(ctx, ec.Recover(ctx, r))
    83  			ret = graphql.Null
    84  		}
    85  	}()
    86  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    87  		ctx = rctx // use context from middleware stack in children
    88  		return obj.Foo, nil
    89  	})
    90  
    91  	if resTmp == nil {
    92  		if !graphql.HasFieldError(ctx, fc) {
    93  			ec.Errorf(ctx, "must not be null")
    94  		}
    95  		return graphql.Null
    96  	}
    97  	res := resTmp.(int)
    98  	fc.Result = res
    99  	return ec.marshalNInt2int(ctx, field.Selections, res)
   100  }
   101  
   102  func (ec *executionContext) fieldContext_OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   103  	fc = &graphql.FieldContext{
   104  		Object:     "OverlappingFields",
   105  		Field:      field,
   106  		IsMethod:   false,
   107  		IsResolver: false,
   108  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   109  			return nil, errors.New("field of type Int does not have child fields")
   110  		},
   111  	}
   112  	return fc, nil
   113  }
   114  
   115  func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
   116  	fc, err := ec.fieldContext_OverlappingFields_oldFoo(ctx, field)
   117  	if err != nil {
   118  		return graphql.Null
   119  	}
   120  	ctx = graphql.WithFieldContext(ctx, fc)
   121  	defer func() {
   122  		if r := recover(); r != nil {
   123  			ec.Error(ctx, ec.Recover(ctx, r))
   124  			ret = graphql.Null
   125  		}
   126  	}()
   127  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   128  		ctx = rctx // use context from middleware stack in children
   129  		return ec.resolvers.OverlappingFields().OldFoo(rctx, obj)
   130  	})
   131  
   132  	if resTmp == nil {
   133  		if !graphql.HasFieldError(ctx, fc) {
   134  			ec.Errorf(ctx, "must not be null")
   135  		}
   136  		return graphql.Null
   137  	}
   138  	res := resTmp.(int)
   139  	fc.Result = res
   140  	return ec.marshalNInt2int(ctx, field.Selections, res)
   141  }
   142  
   143  func (ec *executionContext) fieldContext_OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   144  	fc = &graphql.FieldContext{
   145  		Object:     "OverlappingFields",
   146  		Field:      field,
   147  		IsMethod:   true,
   148  		IsResolver: true,
   149  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   150  			return nil, errors.New("field of type Int does not have child fields")
   151  		},
   152  	}
   153  	return fc, nil
   154  }
   155  
   156  func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
   157  	fc, err := ec.fieldContext_OverlappingFields_newFoo(ctx, field)
   158  	if err != nil {
   159  		return graphql.Null
   160  	}
   161  	ctx = graphql.WithFieldContext(ctx, fc)
   162  	defer func() {
   163  		if r := recover(); r != nil {
   164  			ec.Error(ctx, ec.Recover(ctx, r))
   165  			ret = graphql.Null
   166  		}
   167  	}()
   168  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   169  		ctx = rctx // use context from middleware stack in children
   170  		return obj.NewFoo, nil
   171  	})
   172  
   173  	if resTmp == nil {
   174  		if !graphql.HasFieldError(ctx, fc) {
   175  			ec.Errorf(ctx, "must not be null")
   176  		}
   177  		return graphql.Null
   178  	}
   179  	res := resTmp.(int)
   180  	fc.Result = res
   181  	return ec.marshalNInt2int(ctx, field.Selections, res)
   182  }
   183  
   184  func (ec *executionContext) fieldContext_OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   185  	fc = &graphql.FieldContext{
   186  		Object:     "OverlappingFields",
   187  		Field:      field,
   188  		IsMethod:   false,
   189  		IsResolver: false,
   190  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   191  			return nil, errors.New("field of type Int does not have child fields")
   192  		},
   193  	}
   194  	return fc, nil
   195  }
   196  
   197  func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) {
   198  	fc, err := ec.fieldContext_OverlappingFields_new_foo(ctx, field)
   199  	if err != nil {
   200  		return graphql.Null
   201  	}
   202  	ctx = graphql.WithFieldContext(ctx, fc)
   203  	defer func() {
   204  		if r := recover(); r != nil {
   205  			ec.Error(ctx, ec.Recover(ctx, r))
   206  			ret = graphql.Null
   207  		}
   208  	}()
   209  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   210  		ctx = rctx // use context from middleware stack in children
   211  		return obj.NewFoo, nil
   212  	})
   213  
   214  	if resTmp == nil {
   215  		if !graphql.HasFieldError(ctx, fc) {
   216  			ec.Errorf(ctx, "must not be null")
   217  		}
   218  		return graphql.Null
   219  	}
   220  	res := resTmp.(int)
   221  	fc.Result = res
   222  	return ec.marshalNInt2int(ctx, field.Selections, res)
   223  }
   224  
   225  func (ec *executionContext) fieldContext_OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   226  	fc = &graphql.FieldContext{
   227  		Object:     "OverlappingFields",
   228  		Field:      field,
   229  		IsMethod:   false,
   230  		IsResolver: false,
   231  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   232  			return nil, errors.New("field of type Int does not have child fields")
   233  		},
   234  	}
   235  	return fc, nil
   236  }
   237  
   238  // endregion **************************** field.gotpl *****************************
   239  
   240  // region    **************************** input.gotpl *****************************
   241  
   242  // endregion **************************** input.gotpl *****************************
   243  
   244  // region    ************************** interface.gotpl ***************************
   245  
   246  // endregion ************************** interface.gotpl ***************************
   247  
   248  // region    **************************** object.gotpl ****************************
   249  
   250  var overlappingFieldsImplementors = []string{"OverlappingFields"}
   251  
   252  func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.SelectionSet, obj *OverlappingFields) graphql.Marshaler {
   253  	fields := graphql.CollectFields(ec.OperationContext, sel, overlappingFieldsImplementors)
   254  
   255  	out := graphql.NewFieldSet(fields)
   256  	deferred := make(map[string]*graphql.FieldSet)
   257  	for i, field := range fields {
   258  		switch field.Name {
   259  		case "__typename":
   260  			out.Values[i] = graphql.MarshalString("OverlappingFields")
   261  		case "oneFoo":
   262  			out.Values[i] = ec._OverlappingFields_oneFoo(ctx, field, obj)
   263  			if out.Values[i] == graphql.Null {
   264  				atomic.AddUint32(&out.Invalids, 1)
   265  			}
   266  		case "twoFoo":
   267  			out.Values[i] = ec._OverlappingFields_twoFoo(ctx, field, obj)
   268  			if out.Values[i] == graphql.Null {
   269  				atomic.AddUint32(&out.Invalids, 1)
   270  			}
   271  		case "oldFoo":
   272  			field := field
   273  
   274  			innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
   275  				defer func() {
   276  					if r := recover(); r != nil {
   277  						ec.Error(ctx, ec.Recover(ctx, r))
   278  					}
   279  				}()
   280  				res = ec._OverlappingFields_oldFoo(ctx, field, obj)
   281  				if res == graphql.Null {
   282  					atomic.AddUint32(&fs.Invalids, 1)
   283  				}
   284  				return res
   285  			}
   286  
   287  			if field.Deferrable != nil {
   288  				dfs, ok := deferred[field.Deferrable.Label]
   289  				di := 0
   290  				if ok {
   291  					dfs.AddField(field)
   292  					di = len(dfs.Values) - 1
   293  				} else {
   294  					dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
   295  					deferred[field.Deferrable.Label] = dfs
   296  				}
   297  				dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
   298  					return innerFunc(ctx, dfs)
   299  				})
   300  
   301  				// don't run the out.Concurrently() call below
   302  				out.Values[i] = graphql.Null
   303  				continue
   304  			}
   305  
   306  			out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
   307  		case "newFoo":
   308  			out.Values[i] = ec._OverlappingFields_newFoo(ctx, field, obj)
   309  			if out.Values[i] == graphql.Null {
   310  				atomic.AddUint32(&out.Invalids, 1)
   311  			}
   312  		case "new_foo":
   313  			out.Values[i] = ec._OverlappingFields_new_foo(ctx, field, obj)
   314  			if out.Values[i] == graphql.Null {
   315  				atomic.AddUint32(&out.Invalids, 1)
   316  			}
   317  		default:
   318  			panic("unknown field " + strconv.Quote(field.Name))
   319  		}
   320  	}
   321  	out.Dispatch(ctx)
   322  	if out.Invalids > 0 {
   323  		return graphql.Null
   324  	}
   325  
   326  	atomic.AddInt32(&ec.deferred, int32(len(deferred)))
   327  
   328  	for label, dfs := range deferred {
   329  		ec.processDeferredGroup(graphql.DeferredGroup{
   330  			Label:    label,
   331  			Path:     graphql.GetPath(ctx),
   332  			FieldSet: dfs,
   333  			Context:  ctx,
   334  		})
   335  	}
   336  
   337  	return out
   338  }
   339  
   340  // endregion **************************** object.gotpl ****************************
   341  
   342  // region    ***************************** type.gotpl *****************************
   343  
   344  func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler {
   345  	if v == nil {
   346  		return graphql.Null
   347  	}
   348  	return ec._OverlappingFields(ctx, sel, v)
   349  }
   350  
   351  // endregion ***************************** type.gotpl *****************************
   352  

View as plain text