github.com/operandinc/gqlgen@v0.16.1/codegen/testserver/followschema/panics.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  	"sync/atomic"
     9  
    10  	"github.com/operandinc/gqlgen/graphql"
    11  	"github.com/vektah/gqlparser/v2/ast"
    12  )
    13  
    14  // region    ************************** generated!.gotpl **************************
    15  
    16  type PanicsResolver interface {
    17  	FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error)
    18  
    19  	ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error)
    20  }
    21  
    22  // endregion ************************** generated!.gotpl **************************
    23  
    24  // region    ***************************** args.gotpl *****************************
    25  
    26  func (ec *executionContext) field_Panics_argUnmarshal_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
    27  	var err error
    28  	args := map[string]interface{}{}
    29  	var arg0 []MarshalPanic
    30  	if tmp, ok := rawArgs["u"]; ok {
    31  		ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("u"))
    32  		arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, tmp)
    33  		if err != nil {
    34  			return nil, err
    35  		}
    36  	}
    37  	args["u"] = arg0
    38  	return args, nil
    39  }
    40  
    41  func (ec *executionContext) field_Panics_fieldFuncMarshal_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
    42  	var err error
    43  	args := map[string]interface{}{}
    44  	var arg0 []MarshalPanic
    45  	if tmp, ok := rawArgs["u"]; ok {
    46  		ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("u"))
    47  		arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, tmp)
    48  		if err != nil {
    49  			return nil, err
    50  		}
    51  	}
    52  	args["u"] = arg0
    53  	return args, nil
    54  }
    55  
    56  // endregion ***************************** args.gotpl *****************************
    57  
    58  // region    ************************** directives.gotpl **************************
    59  
    60  // endregion ************************** directives.gotpl **************************
    61  
    62  // region    **************************** field.gotpl *****************************
    63  
    64  func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) {
    65  	defer func() {
    66  		if r := recover(); r != nil {
    67  			ec.Error(ctx, ec.Recover(ctx, r))
    68  			ret = graphql.Null
    69  		}
    70  	}()
    71  	fc := &graphql.FieldContext{
    72  		Object:     "Panics",
    73  		Field:      field,
    74  		Args:       nil,
    75  		IsMethod:   true,
    76  		IsResolver: true,
    77  	}
    78  
    79  	ctx = graphql.WithFieldContext(ctx, fc)
    80  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    81  		ctx = rctx // use context from middleware stack in children
    82  		return ec.resolvers.Panics().FieldScalarMarshal(rctx, obj)
    83  	})
    84  
    85  	if resTmp == nil {
    86  		if !graphql.HasFieldError(ctx, fc) {
    87  			ec.Errorf(ctx, "must not be null")
    88  		}
    89  		return graphql.Null
    90  	}
    91  	res := resTmp.([]MarshalPanic)
    92  	fc.Result = res
    93  	return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, field.Selections, res)
    94  }
    95  
    96  func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) {
    97  	defer func() {
    98  		if r := recover(); r != nil {
    99  			ec.Error(ctx, ec.Recover(ctx, r))
   100  			ret = graphql.Null
   101  		}
   102  	}()
   103  	fc := &graphql.FieldContext{
   104  		Object:     "Panics",
   105  		Field:      field,
   106  		Args:       nil,
   107  		IsMethod:   true,
   108  		IsResolver: false,
   109  	}
   110  
   111  	ctx = graphql.WithFieldContext(ctx, fc)
   112  	rawArgs := field.ArgumentMap(ec.Variables)
   113  	args, err := ec.field_Panics_fieldFuncMarshal_args(ctx, rawArgs)
   114  	if err != nil {
   115  		ec.Error(ctx, err)
   116  		return graphql.Null
   117  	}
   118  	fc.Args = args
   119  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   120  		ctx = rctx // use context from middleware stack in children
   121  		return obj.FieldFuncMarshal(ctx, args["u"].([]MarshalPanic)), nil
   122  	})
   123  
   124  	if resTmp == nil {
   125  		if !graphql.HasFieldError(ctx, fc) {
   126  			ec.Errorf(ctx, "must not be null")
   127  		}
   128  		return graphql.Null
   129  	}
   130  	res := resTmp.([]MarshalPanic)
   131  	fc.Result = res
   132  	return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, field.Selections, res)
   133  }
   134  
   135  func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) {
   136  	defer func() {
   137  		if r := recover(); r != nil {
   138  			ec.Error(ctx, ec.Recover(ctx, r))
   139  			ret = graphql.Null
   140  		}
   141  	}()
   142  	fc := &graphql.FieldContext{
   143  		Object:     "Panics",
   144  		Field:      field,
   145  		Args:       nil,
   146  		IsMethod:   true,
   147  		IsResolver: true,
   148  	}
   149  
   150  	ctx = graphql.WithFieldContext(ctx, fc)
   151  	rawArgs := field.ArgumentMap(ec.Variables)
   152  	args, err := ec.field_Panics_argUnmarshal_args(ctx, rawArgs)
   153  	if err != nil {
   154  		ec.Error(ctx, err)
   155  		return graphql.Null
   156  	}
   157  	fc.Args = args
   158  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   159  		ctx = rctx // use context from middleware stack in children
   160  		return ec.resolvers.Panics().ArgUnmarshal(rctx, obj, args["u"].([]MarshalPanic))
   161  	})
   162  
   163  	if resTmp == nil {
   164  		if !graphql.HasFieldError(ctx, fc) {
   165  			ec.Errorf(ctx, "must not be null")
   166  		}
   167  		return graphql.Null
   168  	}
   169  	res := resTmp.(bool)
   170  	fc.Result = res
   171  	return ec.marshalNBoolean2bool(ctx, field.Selections, res)
   172  }
   173  
   174  // endregion **************************** field.gotpl *****************************
   175  
   176  // region    **************************** input.gotpl *****************************
   177  
   178  // endregion **************************** input.gotpl *****************************
   179  
   180  // region    ************************** interface.gotpl ***************************
   181  
   182  // endregion ************************** interface.gotpl ***************************
   183  
   184  // region    **************************** object.gotpl ****************************
   185  
   186  var panicsImplementors = []string{"Panics"}
   187  
   188  func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, obj *Panics) graphql.Marshaler {
   189  	fields := graphql.CollectFields(ec.OperationContext, sel, panicsImplementors)
   190  	out := graphql.NewFieldSet(fields)
   191  	var invalids uint32
   192  	for i, field := range fields {
   193  		switch field.Name {
   194  		case "__typename":
   195  			out.Values[i] = graphql.MarshalString("Panics")
   196  		case "fieldScalarMarshal":
   197  			field := field
   198  
   199  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   200  				defer func() {
   201  					if r := recover(); r != nil {
   202  						ec.Error(ctx, ec.Recover(ctx, r))
   203  					}
   204  				}()
   205  				res = ec._Panics_fieldScalarMarshal(ctx, field, obj)
   206  				if res == graphql.Null {
   207  					atomic.AddUint32(&invalids, 1)
   208  				}
   209  				return res
   210  			}
   211  
   212  			out.Concurrently(i, func() graphql.Marshaler {
   213  				return innerFunc(ctx)
   214  
   215  			})
   216  		case "fieldFuncMarshal":
   217  			field := field
   218  
   219  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   220  				defer func() {
   221  					if r := recover(); r != nil {
   222  						ec.Error(ctx, ec.Recover(ctx, r))
   223  					}
   224  				}()
   225  				res = ec._Panics_fieldFuncMarshal(ctx, field, obj)
   226  				if res == graphql.Null {
   227  					atomic.AddUint32(&invalids, 1)
   228  				}
   229  				return res
   230  			}
   231  
   232  			out.Concurrently(i, func() graphql.Marshaler {
   233  				return innerFunc(ctx)
   234  
   235  			})
   236  		case "argUnmarshal":
   237  			field := field
   238  
   239  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   240  				defer func() {
   241  					if r := recover(); r != nil {
   242  						ec.Error(ctx, ec.Recover(ctx, r))
   243  					}
   244  				}()
   245  				res = ec._Panics_argUnmarshal(ctx, field, obj)
   246  				if res == graphql.Null {
   247  					atomic.AddUint32(&invalids, 1)
   248  				}
   249  				return res
   250  			}
   251  
   252  			out.Concurrently(i, func() graphql.Marshaler {
   253  				return innerFunc(ctx)
   254  
   255  			})
   256  		default:
   257  			panic("unknown field " + strconv.Quote(field.Name))
   258  		}
   259  	}
   260  	out.Dispatch()
   261  	if invalids > 0 {
   262  		return graphql.Null
   263  	}
   264  	return out
   265  }
   266  
   267  // endregion **************************** object.gotpl ****************************
   268  
   269  // region    ***************************** type.gotpl *****************************
   270  
   271  func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx context.Context, v interface{}) (MarshalPanic, error) {
   272  	var res MarshalPanic
   273  	err := res.UnmarshalGQL(v)
   274  	return res, graphql.ErrorOnPath(ctx, err)
   275  }
   276  
   277  func (ec *executionContext) marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler {
   278  	return v
   279  }
   280  
   281  func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx context.Context, v interface{}) ([]MarshalPanic, error) {
   282  	var vSlice []interface{}
   283  	if v != nil {
   284  		vSlice = graphql.CoerceList(v)
   285  	}
   286  	var err error
   287  	res := make([]MarshalPanic, len(vSlice))
   288  	for i := range vSlice {
   289  		ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
   290  		res[i], err = ec.unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx, vSlice[i])
   291  		if err != nil {
   292  			return nil, err
   293  		}
   294  	}
   295  	return res, nil
   296  }
   297  
   298  func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx context.Context, sel ast.SelectionSet, v []MarshalPanic) graphql.Marshaler {
   299  	ret := make(graphql.Array, len(v))
   300  	for i := range v {
   301  		ret[i] = ec.marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx, sel, v[i])
   302  	}
   303  
   304  	for _, e := range ret {
   305  		if e == graphql.Null {
   306  			return graphql.Null
   307  		}
   308  	}
   309  
   310  	return ret
   311  }
   312  
   313  func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPanics(ctx context.Context, sel ast.SelectionSet, v *Panics) graphql.Marshaler {
   314  	if v == nil {
   315  		return graphql.Null
   316  	}
   317  	return ec._Panics(ctx, sel, v)
   318  }
   319  
   320  // endregion ***************************** type.gotpl *****************************