...

Source file src/github.com/99designs/gqlgen/codegen/testserver/followschema/nulls.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  	"fmt"
     9  	"strconv"
    10  	"sync"
    11  	"sync/atomic"
    12  
    13  	"github.com/99designs/gqlgen/graphql"
    14  	"github.com/vektah/gqlparser/v2/ast"
    15  )
    16  
    17  // region    ************************** generated!.gotpl **************************
    18  
    19  type ErrorsResolver interface {
    20  	A(ctx context.Context, obj *Errors) (*Error, error)
    21  	B(ctx context.Context, obj *Errors) (*Error, error)
    22  	C(ctx context.Context, obj *Errors) (*Error, error)
    23  	D(ctx context.Context, obj *Errors) (*Error, error)
    24  	E(ctx context.Context, obj *Errors) (*Error, error)
    25  }
    26  
    27  // endregion ************************** generated!.gotpl **************************
    28  
    29  // region    ***************************** args.gotpl *****************************
    30  
    31  // endregion ***************************** args.gotpl *****************************
    32  
    33  // region    ************************** directives.gotpl **************************
    34  
    35  // endregion ************************** directives.gotpl **************************
    36  
    37  // region    **************************** field.gotpl *****************************
    38  
    39  func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) {
    40  	fc, err := ec.fieldContext_Error_id(ctx, field)
    41  	if err != nil {
    42  		return graphql.Null
    43  	}
    44  	ctx = graphql.WithFieldContext(ctx, fc)
    45  	defer func() {
    46  		if r := recover(); r != nil {
    47  			ec.Error(ctx, ec.Recover(ctx, r))
    48  			ret = graphql.Null
    49  		}
    50  	}()
    51  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    52  		ctx = rctx // use context from middleware stack in children
    53  		return obj.ID, nil
    54  	})
    55  
    56  	if resTmp == nil {
    57  		if !graphql.HasFieldError(ctx, fc) {
    58  			ec.Errorf(ctx, "must not be null")
    59  		}
    60  		return graphql.Null
    61  	}
    62  	res := resTmp.(string)
    63  	fc.Result = res
    64  	return ec.marshalNID2string(ctx, field.Selections, res)
    65  }
    66  
    67  func (ec *executionContext) fieldContext_Error_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
    68  	fc = &graphql.FieldContext{
    69  		Object:     "Error",
    70  		Field:      field,
    71  		IsMethod:   false,
    72  		IsResolver: false,
    73  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
    74  			return nil, errors.New("field of type ID does not have child fields")
    75  		},
    76  	}
    77  	return fc, nil
    78  }
    79  
    80  func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) {
    81  	fc, err := ec.fieldContext_Error_errorOnNonRequiredField(ctx, field)
    82  	if err != nil {
    83  		return graphql.Null
    84  	}
    85  	ctx = graphql.WithFieldContext(ctx, fc)
    86  	defer func() {
    87  		if r := recover(); r != nil {
    88  			ec.Error(ctx, ec.Recover(ctx, r))
    89  			ret = graphql.Null
    90  		}
    91  	}()
    92  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    93  		ctx = rctx // use context from middleware stack in children
    94  		return obj.ErrorOnNonRequiredField()
    95  	})
    96  
    97  	if resTmp == nil {
    98  		return graphql.Null
    99  	}
   100  	res := resTmp.(string)
   101  	fc.Result = res
   102  	return ec.marshalOString2string(ctx, field.Selections, res)
   103  }
   104  
   105  func (ec *executionContext) fieldContext_Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   106  	fc = &graphql.FieldContext{
   107  		Object:     "Error",
   108  		Field:      field,
   109  		IsMethod:   true,
   110  		IsResolver: false,
   111  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   112  			return nil, errors.New("field of type String does not have child fields")
   113  		},
   114  	}
   115  	return fc, nil
   116  }
   117  
   118  func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) {
   119  	fc, err := ec.fieldContext_Error_errorOnRequiredField(ctx, field)
   120  	if err != nil {
   121  		return graphql.Null
   122  	}
   123  	ctx = graphql.WithFieldContext(ctx, fc)
   124  	defer func() {
   125  		if r := recover(); r != nil {
   126  			ec.Error(ctx, ec.Recover(ctx, r))
   127  			ret = graphql.Null
   128  		}
   129  	}()
   130  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   131  		ctx = rctx // use context from middleware stack in children
   132  		return obj.ErrorOnRequiredField()
   133  	})
   134  
   135  	if resTmp == nil {
   136  		if !graphql.HasFieldError(ctx, fc) {
   137  			ec.Errorf(ctx, "must not be null")
   138  		}
   139  		return graphql.Null
   140  	}
   141  	res := resTmp.(string)
   142  	fc.Result = res
   143  	return ec.marshalNString2string(ctx, field.Selections, res)
   144  }
   145  
   146  func (ec *executionContext) fieldContext_Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   147  	fc = &graphql.FieldContext{
   148  		Object:     "Error",
   149  		Field:      field,
   150  		IsMethod:   true,
   151  		IsResolver: false,
   152  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   153  			return nil, errors.New("field of type String does not have child fields")
   154  		},
   155  	}
   156  	return fc, nil
   157  }
   158  
   159  func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) {
   160  	fc, err := ec.fieldContext_Error_nilOnRequiredField(ctx, field)
   161  	if err != nil {
   162  		return graphql.Null
   163  	}
   164  	ctx = graphql.WithFieldContext(ctx, fc)
   165  	defer func() {
   166  		if r := recover(); r != nil {
   167  			ec.Error(ctx, ec.Recover(ctx, r))
   168  			ret = graphql.Null
   169  		}
   170  	}()
   171  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   172  		ctx = rctx // use context from middleware stack in children
   173  		return obj.NilOnRequiredField(), nil
   174  	})
   175  
   176  	if resTmp == nil {
   177  		if !graphql.HasFieldError(ctx, fc) {
   178  			ec.Errorf(ctx, "must not be null")
   179  		}
   180  		return graphql.Null
   181  	}
   182  	res := resTmp.(*string)
   183  	fc.Result = res
   184  	return ec.marshalNString2ᚖstring(ctx, field.Selections, res)
   185  }
   186  
   187  func (ec *executionContext) fieldContext_Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   188  	fc = &graphql.FieldContext{
   189  		Object:     "Error",
   190  		Field:      field,
   191  		IsMethod:   true,
   192  		IsResolver: false,
   193  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   194  			return nil, errors.New("field of type String does not have child fields")
   195  		},
   196  	}
   197  	return fc, nil
   198  }
   199  
   200  func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
   201  	fc, err := ec.fieldContext_Errors_a(ctx, field)
   202  	if err != nil {
   203  		return graphql.Null
   204  	}
   205  	ctx = graphql.WithFieldContext(ctx, fc)
   206  	defer func() {
   207  		if r := recover(); r != nil {
   208  			ec.Error(ctx, ec.Recover(ctx, r))
   209  			ret = graphql.Null
   210  		}
   211  	}()
   212  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   213  		ctx = rctx // use context from middleware stack in children
   214  		return ec.resolvers.Errors().A(rctx, obj)
   215  	})
   216  
   217  	if resTmp == nil {
   218  		if !graphql.HasFieldError(ctx, fc) {
   219  			ec.Errorf(ctx, "must not be null")
   220  		}
   221  		return graphql.Null
   222  	}
   223  	res := resTmp.(*Error)
   224  	fc.Result = res
   225  	return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
   226  }
   227  
   228  func (ec *executionContext) fieldContext_Errors_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   229  	fc = &graphql.FieldContext{
   230  		Object:     "Errors",
   231  		Field:      field,
   232  		IsMethod:   true,
   233  		IsResolver: true,
   234  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   235  			switch field.Name {
   236  			case "id":
   237  				return ec.fieldContext_Error_id(ctx, field)
   238  			case "errorOnNonRequiredField":
   239  				return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field)
   240  			case "errorOnRequiredField":
   241  				return ec.fieldContext_Error_errorOnRequiredField(ctx, field)
   242  			case "nilOnRequiredField":
   243  				return ec.fieldContext_Error_nilOnRequiredField(ctx, field)
   244  			}
   245  			return nil, fmt.Errorf("no field named %q was found under type Error", field.Name)
   246  		},
   247  	}
   248  	return fc, nil
   249  }
   250  
   251  func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
   252  	fc, err := ec.fieldContext_Errors_b(ctx, field)
   253  	if err != nil {
   254  		return graphql.Null
   255  	}
   256  	ctx = graphql.WithFieldContext(ctx, fc)
   257  	defer func() {
   258  		if r := recover(); r != nil {
   259  			ec.Error(ctx, ec.Recover(ctx, r))
   260  			ret = graphql.Null
   261  		}
   262  	}()
   263  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   264  		ctx = rctx // use context from middleware stack in children
   265  		return ec.resolvers.Errors().B(rctx, obj)
   266  	})
   267  
   268  	if resTmp == nil {
   269  		if !graphql.HasFieldError(ctx, fc) {
   270  			ec.Errorf(ctx, "must not be null")
   271  		}
   272  		return graphql.Null
   273  	}
   274  	res := resTmp.(*Error)
   275  	fc.Result = res
   276  	return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
   277  }
   278  
   279  func (ec *executionContext) fieldContext_Errors_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   280  	fc = &graphql.FieldContext{
   281  		Object:     "Errors",
   282  		Field:      field,
   283  		IsMethod:   true,
   284  		IsResolver: true,
   285  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   286  			switch field.Name {
   287  			case "id":
   288  				return ec.fieldContext_Error_id(ctx, field)
   289  			case "errorOnNonRequiredField":
   290  				return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field)
   291  			case "errorOnRequiredField":
   292  				return ec.fieldContext_Error_errorOnRequiredField(ctx, field)
   293  			case "nilOnRequiredField":
   294  				return ec.fieldContext_Error_nilOnRequiredField(ctx, field)
   295  			}
   296  			return nil, fmt.Errorf("no field named %q was found under type Error", field.Name)
   297  		},
   298  	}
   299  	return fc, nil
   300  }
   301  
   302  func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
   303  	fc, err := ec.fieldContext_Errors_c(ctx, field)
   304  	if err != nil {
   305  		return graphql.Null
   306  	}
   307  	ctx = graphql.WithFieldContext(ctx, fc)
   308  	defer func() {
   309  		if r := recover(); r != nil {
   310  			ec.Error(ctx, ec.Recover(ctx, r))
   311  			ret = graphql.Null
   312  		}
   313  	}()
   314  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   315  		ctx = rctx // use context from middleware stack in children
   316  		return ec.resolvers.Errors().C(rctx, obj)
   317  	})
   318  
   319  	if resTmp == nil {
   320  		if !graphql.HasFieldError(ctx, fc) {
   321  			ec.Errorf(ctx, "must not be null")
   322  		}
   323  		return graphql.Null
   324  	}
   325  	res := resTmp.(*Error)
   326  	fc.Result = res
   327  	return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
   328  }
   329  
   330  func (ec *executionContext) fieldContext_Errors_c(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   331  	fc = &graphql.FieldContext{
   332  		Object:     "Errors",
   333  		Field:      field,
   334  		IsMethod:   true,
   335  		IsResolver: true,
   336  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   337  			switch field.Name {
   338  			case "id":
   339  				return ec.fieldContext_Error_id(ctx, field)
   340  			case "errorOnNonRequiredField":
   341  				return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field)
   342  			case "errorOnRequiredField":
   343  				return ec.fieldContext_Error_errorOnRequiredField(ctx, field)
   344  			case "nilOnRequiredField":
   345  				return ec.fieldContext_Error_nilOnRequiredField(ctx, field)
   346  			}
   347  			return nil, fmt.Errorf("no field named %q was found under type Error", field.Name)
   348  		},
   349  	}
   350  	return fc, nil
   351  }
   352  
   353  func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
   354  	fc, err := ec.fieldContext_Errors_d(ctx, field)
   355  	if err != nil {
   356  		return graphql.Null
   357  	}
   358  	ctx = graphql.WithFieldContext(ctx, fc)
   359  	defer func() {
   360  		if r := recover(); r != nil {
   361  			ec.Error(ctx, ec.Recover(ctx, r))
   362  			ret = graphql.Null
   363  		}
   364  	}()
   365  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   366  		ctx = rctx // use context from middleware stack in children
   367  		return ec.resolvers.Errors().D(rctx, obj)
   368  	})
   369  
   370  	if resTmp == nil {
   371  		if !graphql.HasFieldError(ctx, fc) {
   372  			ec.Errorf(ctx, "must not be null")
   373  		}
   374  		return graphql.Null
   375  	}
   376  	res := resTmp.(*Error)
   377  	fc.Result = res
   378  	return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
   379  }
   380  
   381  func (ec *executionContext) fieldContext_Errors_d(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   382  	fc = &graphql.FieldContext{
   383  		Object:     "Errors",
   384  		Field:      field,
   385  		IsMethod:   true,
   386  		IsResolver: true,
   387  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   388  			switch field.Name {
   389  			case "id":
   390  				return ec.fieldContext_Error_id(ctx, field)
   391  			case "errorOnNonRequiredField":
   392  				return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field)
   393  			case "errorOnRequiredField":
   394  				return ec.fieldContext_Error_errorOnRequiredField(ctx, field)
   395  			case "nilOnRequiredField":
   396  				return ec.fieldContext_Error_nilOnRequiredField(ctx, field)
   397  			}
   398  			return nil, fmt.Errorf("no field named %q was found under type Error", field.Name)
   399  		},
   400  	}
   401  	return fc, nil
   402  }
   403  
   404  func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) {
   405  	fc, err := ec.fieldContext_Errors_e(ctx, field)
   406  	if err != nil {
   407  		return graphql.Null
   408  	}
   409  	ctx = graphql.WithFieldContext(ctx, fc)
   410  	defer func() {
   411  		if r := recover(); r != nil {
   412  			ec.Error(ctx, ec.Recover(ctx, r))
   413  			ret = graphql.Null
   414  		}
   415  	}()
   416  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   417  		ctx = rctx // use context from middleware stack in children
   418  		return ec.resolvers.Errors().E(rctx, obj)
   419  	})
   420  
   421  	if resTmp == nil {
   422  		if !graphql.HasFieldError(ctx, fc) {
   423  			ec.Errorf(ctx, "must not be null")
   424  		}
   425  		return graphql.Null
   426  	}
   427  	res := resTmp.(*Error)
   428  	fc.Result = res
   429  	return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res)
   430  }
   431  
   432  func (ec *executionContext) fieldContext_Errors_e(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   433  	fc = &graphql.FieldContext{
   434  		Object:     "Errors",
   435  		Field:      field,
   436  		IsMethod:   true,
   437  		IsResolver: true,
   438  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   439  			switch field.Name {
   440  			case "id":
   441  				return ec.fieldContext_Error_id(ctx, field)
   442  			case "errorOnNonRequiredField":
   443  				return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field)
   444  			case "errorOnRequiredField":
   445  				return ec.fieldContext_Error_errorOnRequiredField(ctx, field)
   446  			case "nilOnRequiredField":
   447  				return ec.fieldContext_Error_nilOnRequiredField(ctx, field)
   448  			}
   449  			return nil, fmt.Errorf("no field named %q was found under type Error", field.Name)
   450  		},
   451  	}
   452  	return fc, nil
   453  }
   454  
   455  // endregion **************************** field.gotpl *****************************
   456  
   457  // region    **************************** input.gotpl *****************************
   458  
   459  // endregion **************************** input.gotpl *****************************
   460  
   461  // region    ************************** interface.gotpl ***************************
   462  
   463  // endregion ************************** interface.gotpl ***************************
   464  
   465  // region    **************************** object.gotpl ****************************
   466  
   467  var errorImplementors = []string{"Error"}
   468  
   469  func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler {
   470  	fields := graphql.CollectFields(ec.OperationContext, sel, errorImplementors)
   471  
   472  	out := graphql.NewFieldSet(fields)
   473  	deferred := make(map[string]*graphql.FieldSet)
   474  	for i, field := range fields {
   475  		switch field.Name {
   476  		case "__typename":
   477  			out.Values[i] = graphql.MarshalString("Error")
   478  		case "id":
   479  			out.Values[i] = ec._Error_id(ctx, field, obj)
   480  			if out.Values[i] == graphql.Null {
   481  				out.Invalids++
   482  			}
   483  		case "errorOnNonRequiredField":
   484  			out.Values[i] = ec._Error_errorOnNonRequiredField(ctx, field, obj)
   485  		case "errorOnRequiredField":
   486  			out.Values[i] = ec._Error_errorOnRequiredField(ctx, field, obj)
   487  			if out.Values[i] == graphql.Null {
   488  				out.Invalids++
   489  			}
   490  		case "nilOnRequiredField":
   491  			out.Values[i] = ec._Error_nilOnRequiredField(ctx, field, obj)
   492  			if out.Values[i] == graphql.Null {
   493  				out.Invalids++
   494  			}
   495  		default:
   496  			panic("unknown field " + strconv.Quote(field.Name))
   497  		}
   498  	}
   499  	out.Dispatch(ctx)
   500  	if out.Invalids > 0 {
   501  		return graphql.Null
   502  	}
   503  
   504  	atomic.AddInt32(&ec.deferred, int32(len(deferred)))
   505  
   506  	for label, dfs := range deferred {
   507  		ec.processDeferredGroup(graphql.DeferredGroup{
   508  			Label:    label,
   509  			Path:     graphql.GetPath(ctx),
   510  			FieldSet: dfs,
   511  			Context:  ctx,
   512  		})
   513  	}
   514  
   515  	return out
   516  }
   517  
   518  var errorsImplementors = []string{"Errors"}
   519  
   520  func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, obj *Errors) graphql.Marshaler {
   521  	fields := graphql.CollectFields(ec.OperationContext, sel, errorsImplementors)
   522  
   523  	out := graphql.NewFieldSet(fields)
   524  	deferred := make(map[string]*graphql.FieldSet)
   525  	for i, field := range fields {
   526  		switch field.Name {
   527  		case "__typename":
   528  			out.Values[i] = graphql.MarshalString("Errors")
   529  		case "a":
   530  			field := field
   531  
   532  			innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
   533  				defer func() {
   534  					if r := recover(); r != nil {
   535  						ec.Error(ctx, ec.Recover(ctx, r))
   536  					}
   537  				}()
   538  				res = ec._Errors_a(ctx, field, obj)
   539  				if res == graphql.Null {
   540  					atomic.AddUint32(&fs.Invalids, 1)
   541  				}
   542  				return res
   543  			}
   544  
   545  			if field.Deferrable != nil {
   546  				dfs, ok := deferred[field.Deferrable.Label]
   547  				di := 0
   548  				if ok {
   549  					dfs.AddField(field)
   550  					di = len(dfs.Values) - 1
   551  				} else {
   552  					dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
   553  					deferred[field.Deferrable.Label] = dfs
   554  				}
   555  				dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
   556  					return innerFunc(ctx, dfs)
   557  				})
   558  
   559  				// don't run the out.Concurrently() call below
   560  				out.Values[i] = graphql.Null
   561  				continue
   562  			}
   563  
   564  			out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
   565  		case "b":
   566  			field := field
   567  
   568  			innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
   569  				defer func() {
   570  					if r := recover(); r != nil {
   571  						ec.Error(ctx, ec.Recover(ctx, r))
   572  					}
   573  				}()
   574  				res = ec._Errors_b(ctx, field, obj)
   575  				if res == graphql.Null {
   576  					atomic.AddUint32(&fs.Invalids, 1)
   577  				}
   578  				return res
   579  			}
   580  
   581  			if field.Deferrable != nil {
   582  				dfs, ok := deferred[field.Deferrable.Label]
   583  				di := 0
   584  				if ok {
   585  					dfs.AddField(field)
   586  					di = len(dfs.Values) - 1
   587  				} else {
   588  					dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
   589  					deferred[field.Deferrable.Label] = dfs
   590  				}
   591  				dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
   592  					return innerFunc(ctx, dfs)
   593  				})
   594  
   595  				// don't run the out.Concurrently() call below
   596  				out.Values[i] = graphql.Null
   597  				continue
   598  			}
   599  
   600  			out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
   601  		case "c":
   602  			field := field
   603  
   604  			innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
   605  				defer func() {
   606  					if r := recover(); r != nil {
   607  						ec.Error(ctx, ec.Recover(ctx, r))
   608  					}
   609  				}()
   610  				res = ec._Errors_c(ctx, field, obj)
   611  				if res == graphql.Null {
   612  					atomic.AddUint32(&fs.Invalids, 1)
   613  				}
   614  				return res
   615  			}
   616  
   617  			if field.Deferrable != nil {
   618  				dfs, ok := deferred[field.Deferrable.Label]
   619  				di := 0
   620  				if ok {
   621  					dfs.AddField(field)
   622  					di = len(dfs.Values) - 1
   623  				} else {
   624  					dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
   625  					deferred[field.Deferrable.Label] = dfs
   626  				}
   627  				dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
   628  					return innerFunc(ctx, dfs)
   629  				})
   630  
   631  				// don't run the out.Concurrently() call below
   632  				out.Values[i] = graphql.Null
   633  				continue
   634  			}
   635  
   636  			out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
   637  		case "d":
   638  			field := field
   639  
   640  			innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
   641  				defer func() {
   642  					if r := recover(); r != nil {
   643  						ec.Error(ctx, ec.Recover(ctx, r))
   644  					}
   645  				}()
   646  				res = ec._Errors_d(ctx, field, obj)
   647  				if res == graphql.Null {
   648  					atomic.AddUint32(&fs.Invalids, 1)
   649  				}
   650  				return res
   651  			}
   652  
   653  			if field.Deferrable != nil {
   654  				dfs, ok := deferred[field.Deferrable.Label]
   655  				di := 0
   656  				if ok {
   657  					dfs.AddField(field)
   658  					di = len(dfs.Values) - 1
   659  				} else {
   660  					dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
   661  					deferred[field.Deferrable.Label] = dfs
   662  				}
   663  				dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
   664  					return innerFunc(ctx, dfs)
   665  				})
   666  
   667  				// don't run the out.Concurrently() call below
   668  				out.Values[i] = graphql.Null
   669  				continue
   670  			}
   671  
   672  			out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
   673  		case "e":
   674  			field := field
   675  
   676  			innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
   677  				defer func() {
   678  					if r := recover(); r != nil {
   679  						ec.Error(ctx, ec.Recover(ctx, r))
   680  					}
   681  				}()
   682  				res = ec._Errors_e(ctx, field, obj)
   683  				if res == graphql.Null {
   684  					atomic.AddUint32(&fs.Invalids, 1)
   685  				}
   686  				return res
   687  			}
   688  
   689  			if field.Deferrable != nil {
   690  				dfs, ok := deferred[field.Deferrable.Label]
   691  				di := 0
   692  				if ok {
   693  					dfs.AddField(field)
   694  					di = len(dfs.Values) - 1
   695  				} else {
   696  					dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
   697  					deferred[field.Deferrable.Label] = dfs
   698  				}
   699  				dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
   700  					return innerFunc(ctx, dfs)
   701  				})
   702  
   703  				// don't run the out.Concurrently() call below
   704  				out.Values[i] = graphql.Null
   705  				continue
   706  			}
   707  
   708  			out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
   709  		default:
   710  			panic("unknown field " + strconv.Quote(field.Name))
   711  		}
   712  	}
   713  	out.Dispatch(ctx)
   714  	if out.Invalids > 0 {
   715  		return graphql.Null
   716  	}
   717  
   718  	atomic.AddInt32(&ec.deferred, int32(len(deferred)))
   719  
   720  	for label, dfs := range deferred {
   721  		ec.processDeferredGroup(graphql.DeferredGroup{
   722  			Label:    label,
   723  			Path:     graphql.GetPath(ctx),
   724  			FieldSet: dfs,
   725  			Context:  ctx,
   726  		})
   727  	}
   728  
   729  	return out
   730  }
   731  
   732  // endregion **************************** object.gotpl ****************************
   733  
   734  // region    ***************************** type.gotpl *****************************
   735  
   736  func (ec *executionContext) marshalNError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler {
   737  	return ec._Error(ctx, sel, &v)
   738  }
   739  
   740  func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
   741  	if v == nil {
   742  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   743  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   744  		}
   745  		return graphql.Null
   746  	}
   747  	return ec._Error(ctx, sel, v)
   748  }
   749  
   750  func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler {
   751  	if v == nil {
   752  		return graphql.Null
   753  	}
   754  	ret := make(graphql.Array, len(v))
   755  	var wg sync.WaitGroup
   756  	isLen1 := len(v) == 1
   757  	if !isLen1 {
   758  		wg.Add(len(v))
   759  	}
   760  	for i := range v {
   761  		i := i
   762  		fc := &graphql.FieldContext{
   763  			Index:  &i,
   764  			Result: &v[i],
   765  		}
   766  		ctx := graphql.WithFieldContext(ctx, fc)
   767  		f := func(i int) {
   768  			defer func() {
   769  				if r := recover(); r != nil {
   770  					ec.Error(ctx, ec.Recover(ctx, r))
   771  					ret = nil
   772  				}
   773  			}()
   774  			if !isLen1 {
   775  				defer wg.Done()
   776  			}
   777  			ret[i] = ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, sel, v[i])
   778  		}
   779  		if isLen1 {
   780  			f(i)
   781  		} else {
   782  			go f(i)
   783  		}
   784  
   785  	}
   786  	wg.Wait()
   787  
   788  	return ret
   789  }
   790  
   791  func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler {
   792  	if v == nil {
   793  		return graphql.Null
   794  	}
   795  	ret := make(graphql.Array, len(v))
   796  	var wg sync.WaitGroup
   797  	isLen1 := len(v) == 1
   798  	if !isLen1 {
   799  		wg.Add(len(v))
   800  	}
   801  	for i := range v {
   802  		i := i
   803  		fc := &graphql.FieldContext{
   804  			Index:  &i,
   805  			Result: &v[i],
   806  		}
   807  		ctx := graphql.WithFieldContext(ctx, fc)
   808  		f := func(i int) {
   809  			defer func() {
   810  				if r := recover(); r != nil {
   811  					ec.Error(ctx, ec.Recover(ctx, r))
   812  					ret = nil
   813  				}
   814  			}()
   815  			if !isLen1 {
   816  				defer wg.Done()
   817  			}
   818  			ret[i] = ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, sel, v[i])
   819  		}
   820  		if isLen1 {
   821  			f(i)
   822  		} else {
   823  			go f(i)
   824  		}
   825  
   826  	}
   827  	wg.Wait()
   828  
   829  	for _, e := range ret {
   830  		if e == graphql.Null {
   831  			return graphql.Null
   832  		}
   833  	}
   834  
   835  	return ret
   836  }
   837  
   838  func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
   839  	if v == nil {
   840  		return graphql.Null
   841  	}
   842  	return ec._Error(ctx, sel, v)
   843  }
   844  
   845  func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler {
   846  	if v == nil {
   847  		return graphql.Null
   848  	}
   849  	return ec._Errors(ctx, sel, v)
   850  }
   851  
   852  // endregion ***************************** type.gotpl *****************************
   853  

View as plain text