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

     1  // Code generated by github.com/luciferinlove/gqlgen, DO NOT EDIT.
     2  
     3  package followschema
     4  
     5  import (
     6  	"context"
     7  	"errors"
     8  	"strconv"
     9  	"sync/atomic"
    10  
    11  	"github.com/luciferinlove/gqlgen/codegen/testserver/followschema/otherpkg"
    12  	"github.com/luciferinlove/gqlgen/graphql"
    13  	"github.com/vektah/gqlparser/v2/ast"
    14  )
    15  
    16  // region    ************************** generated!.gotpl **************************
    17  
    18  type WrappedMapResolver interface {
    19  	Get(ctx context.Context, obj WrappedMap, key string) (string, error)
    20  }
    21  type WrappedSliceResolver interface {
    22  	Get(ctx context.Context, obj WrappedSlice, idx int) (string, error)
    23  }
    24  
    25  // endregion ************************** generated!.gotpl **************************
    26  
    27  // region    ***************************** args.gotpl *****************************
    28  
    29  func (ec *executionContext) field_WrappedMap_get_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
    30  	var err error
    31  	args := map[string]interface{}{}
    32  	var arg0 string
    33  	if tmp, ok := rawArgs["key"]; ok {
    34  		ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key"))
    35  		arg0, err = ec.unmarshalNString2string(ctx, tmp)
    36  		if err != nil {
    37  			return nil, err
    38  		}
    39  	}
    40  	args["key"] = arg0
    41  	return args, nil
    42  }
    43  
    44  func (ec *executionContext) field_WrappedSlice_get_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
    45  	var err error
    46  	args := map[string]interface{}{}
    47  	var arg0 int
    48  	if tmp, ok := rawArgs["idx"]; ok {
    49  		ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idx"))
    50  		arg0, err = ec.unmarshalNInt2int(ctx, tmp)
    51  		if err != nil {
    52  			return nil, err
    53  		}
    54  	}
    55  	args["idx"] = arg0
    56  	return args, nil
    57  }
    58  
    59  // endregion ***************************** args.gotpl *****************************
    60  
    61  // region    ************************** directives.gotpl **************************
    62  
    63  // endregion ************************** directives.gotpl **************************
    64  
    65  // region    **************************** field.gotpl *****************************
    66  
    67  func (ec *executionContext) _WrappedMap_get(ctx context.Context, field graphql.CollectedField, obj WrappedMap) (ret graphql.Marshaler) {
    68  	fc, err := ec.fieldContext_WrappedMap_get(ctx, field)
    69  	if err != nil {
    70  		return graphql.Null
    71  	}
    72  	ctx = graphql.WithFieldContext(ctx, fc)
    73  	defer func() {
    74  		if r := recover(); r != nil {
    75  			ec.Error(ctx, ec.Recover(ctx, r))
    76  			ret = graphql.Null
    77  		}
    78  	}()
    79  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    80  		ctx = rctx // use context from middleware stack in children
    81  		return ec.resolvers.WrappedMap().Get(rctx, obj, fc.Args["key"].(string))
    82  	})
    83  
    84  	if resTmp == nil {
    85  		if !graphql.HasFieldError(ctx, fc) {
    86  			ec.Errorf(ctx, "must not be null")
    87  		}
    88  		return graphql.Null
    89  	}
    90  	res := resTmp.(string)
    91  	fc.Result = res
    92  	return ec.marshalNString2string(ctx, field.Selections, res)
    93  }
    94  
    95  func (ec *executionContext) fieldContext_WrappedMap_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
    96  	fc = &graphql.FieldContext{
    97  		Object:     "WrappedMap",
    98  		Field:      field,
    99  		IsMethod:   true,
   100  		IsResolver: true,
   101  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   102  			return nil, errors.New("field of type String does not have child fields")
   103  		},
   104  	}
   105  	defer func() {
   106  		if r := recover(); r != nil {
   107  			err = ec.Recover(ctx, r)
   108  			ec.Error(ctx, err)
   109  		}
   110  	}()
   111  	ctx = graphql.WithFieldContext(ctx, fc)
   112  	if fc.Args, err = ec.field_WrappedMap_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
   113  		ec.Error(ctx, err)
   114  		return
   115  	}
   116  	return fc, nil
   117  }
   118  
   119  func (ec *executionContext) _WrappedSlice_get(ctx context.Context, field graphql.CollectedField, obj WrappedSlice) (ret graphql.Marshaler) {
   120  	fc, err := ec.fieldContext_WrappedSlice_get(ctx, field)
   121  	if err != nil {
   122  		return graphql.Null
   123  	}
   124  	ctx = graphql.WithFieldContext(ctx, fc)
   125  	defer func() {
   126  		if r := recover(); r != nil {
   127  			ec.Error(ctx, ec.Recover(ctx, r))
   128  			ret = graphql.Null
   129  		}
   130  	}()
   131  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   132  		ctx = rctx // use context from middleware stack in children
   133  		return ec.resolvers.WrappedSlice().Get(rctx, obj, fc.Args["idx"].(int))
   134  	})
   135  
   136  	if resTmp == nil {
   137  		if !graphql.HasFieldError(ctx, fc) {
   138  			ec.Errorf(ctx, "must not be null")
   139  		}
   140  		return graphql.Null
   141  	}
   142  	res := resTmp.(string)
   143  	fc.Result = res
   144  	return ec.marshalNString2string(ctx, field.Selections, res)
   145  }
   146  
   147  func (ec *executionContext) fieldContext_WrappedSlice_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   148  	fc = &graphql.FieldContext{
   149  		Object:     "WrappedSlice",
   150  		Field:      field,
   151  		IsMethod:   true,
   152  		IsResolver: true,
   153  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   154  			return nil, errors.New("field of type String does not have child fields")
   155  		},
   156  	}
   157  	defer func() {
   158  		if r := recover(); r != nil {
   159  			err = ec.Recover(ctx, r)
   160  			ec.Error(ctx, err)
   161  		}
   162  	}()
   163  	ctx = graphql.WithFieldContext(ctx, fc)
   164  	if fc.Args, err = ec.field_WrappedSlice_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
   165  		ec.Error(ctx, err)
   166  		return
   167  	}
   168  	return fc, nil
   169  }
   170  
   171  func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) {
   172  	fc, err := ec.fieldContext_WrappedStruct_name(ctx, field)
   173  	if err != nil {
   174  		return graphql.Null
   175  	}
   176  	ctx = graphql.WithFieldContext(ctx, fc)
   177  	defer func() {
   178  		if r := recover(); r != nil {
   179  			ec.Error(ctx, ec.Recover(ctx, r))
   180  			ret = graphql.Null
   181  		}
   182  	}()
   183  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   184  		ctx = rctx // use context from middleware stack in children
   185  		return obj.Name, nil
   186  	})
   187  
   188  	if resTmp == nil {
   189  		if !graphql.HasFieldError(ctx, fc) {
   190  			ec.Errorf(ctx, "must not be null")
   191  		}
   192  		return graphql.Null
   193  	}
   194  	res := resTmp.(otherpkg.Scalar)
   195  	fc.Result = res
   196  	return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx, field.Selections, res)
   197  }
   198  
   199  func (ec *executionContext) fieldContext_WrappedStruct_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   200  	fc = &graphql.FieldContext{
   201  		Object:     "WrappedStruct",
   202  		Field:      field,
   203  		IsMethod:   false,
   204  		IsResolver: false,
   205  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   206  			return nil, errors.New("field of type WrappedScalar does not have child fields")
   207  		},
   208  	}
   209  	return fc, nil
   210  }
   211  
   212  func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) {
   213  	fc, err := ec.fieldContext_WrappedStruct_desc(ctx, field)
   214  	if err != nil {
   215  		return graphql.Null
   216  	}
   217  	ctx = graphql.WithFieldContext(ctx, fc)
   218  	defer func() {
   219  		if r := recover(); r != nil {
   220  			ec.Error(ctx, ec.Recover(ctx, r))
   221  			ret = graphql.Null
   222  		}
   223  	}()
   224  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   225  		ctx = rctx // use context from middleware stack in children
   226  		return obj.Desc, nil
   227  	})
   228  
   229  	if resTmp == nil {
   230  		return graphql.Null
   231  	}
   232  	res := resTmp.(*otherpkg.Scalar)
   233  	fc.Result = res
   234  	return ec.marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx, field.Selections, res)
   235  }
   236  
   237  func (ec *executionContext) fieldContext_WrappedStruct_desc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   238  	fc = &graphql.FieldContext{
   239  		Object:     "WrappedStruct",
   240  		Field:      field,
   241  		IsMethod:   false,
   242  		IsResolver: false,
   243  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   244  			return nil, errors.New("field of type WrappedScalar does not have child fields")
   245  		},
   246  	}
   247  	return fc, nil
   248  }
   249  
   250  // endregion **************************** field.gotpl *****************************
   251  
   252  // region    **************************** input.gotpl *****************************
   253  
   254  // endregion **************************** input.gotpl *****************************
   255  
   256  // region    ************************** interface.gotpl ***************************
   257  
   258  // endregion ************************** interface.gotpl ***************************
   259  
   260  // region    **************************** object.gotpl ****************************
   261  
   262  var wrappedMapImplementors = []string{"WrappedMap"}
   263  
   264  func (ec *executionContext) _WrappedMap(ctx context.Context, sel ast.SelectionSet, obj WrappedMap) graphql.Marshaler {
   265  	fields := graphql.CollectFields(ec.OperationContext, sel, wrappedMapImplementors)
   266  	out := graphql.NewFieldSet(fields)
   267  	var invalids uint32
   268  	for i, field := range fields {
   269  		switch field.Name {
   270  		case "__typename":
   271  			out.Values[i] = graphql.MarshalString("WrappedMap")
   272  		case "get":
   273  			field := field
   274  
   275  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   276  				defer func() {
   277  					if r := recover(); r != nil {
   278  						ec.Error(ctx, ec.Recover(ctx, r))
   279  					}
   280  				}()
   281  				res = ec._WrappedMap_get(ctx, field, obj)
   282  				if res == graphql.Null {
   283  					atomic.AddUint32(&invalids, 1)
   284  				}
   285  				return res
   286  			}
   287  
   288  			out.Concurrently(i, func() graphql.Marshaler {
   289  				return innerFunc(ctx)
   290  
   291  			})
   292  		default:
   293  			panic("unknown field " + strconv.Quote(field.Name))
   294  		}
   295  	}
   296  	out.Dispatch()
   297  	if invalids > 0 {
   298  		return graphql.Null
   299  	}
   300  	return out
   301  }
   302  
   303  var wrappedSliceImplementors = []string{"WrappedSlice"}
   304  
   305  func (ec *executionContext) _WrappedSlice(ctx context.Context, sel ast.SelectionSet, obj WrappedSlice) graphql.Marshaler {
   306  	fields := graphql.CollectFields(ec.OperationContext, sel, wrappedSliceImplementors)
   307  	out := graphql.NewFieldSet(fields)
   308  	var invalids uint32
   309  	for i, field := range fields {
   310  		switch field.Name {
   311  		case "__typename":
   312  			out.Values[i] = graphql.MarshalString("WrappedSlice")
   313  		case "get":
   314  			field := field
   315  
   316  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   317  				defer func() {
   318  					if r := recover(); r != nil {
   319  						ec.Error(ctx, ec.Recover(ctx, r))
   320  					}
   321  				}()
   322  				res = ec._WrappedSlice_get(ctx, field, obj)
   323  				if res == graphql.Null {
   324  					atomic.AddUint32(&invalids, 1)
   325  				}
   326  				return res
   327  			}
   328  
   329  			out.Concurrently(i, func() graphql.Marshaler {
   330  				return innerFunc(ctx)
   331  
   332  			})
   333  		default:
   334  			panic("unknown field " + strconv.Quote(field.Name))
   335  		}
   336  	}
   337  	out.Dispatch()
   338  	if invalids > 0 {
   339  		return graphql.Null
   340  	}
   341  	return out
   342  }
   343  
   344  var wrappedStructImplementors = []string{"WrappedStruct"}
   345  
   346  func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.SelectionSet, obj *WrappedStruct) graphql.Marshaler {
   347  	fields := graphql.CollectFields(ec.OperationContext, sel, wrappedStructImplementors)
   348  	out := graphql.NewFieldSet(fields)
   349  	var invalids uint32
   350  	for i, field := range fields {
   351  		switch field.Name {
   352  		case "__typename":
   353  			out.Values[i] = graphql.MarshalString("WrappedStruct")
   354  		case "name":
   355  
   356  			out.Values[i] = ec._WrappedStruct_name(ctx, field, obj)
   357  
   358  			if out.Values[i] == graphql.Null {
   359  				invalids++
   360  			}
   361  		case "desc":
   362  
   363  			out.Values[i] = ec._WrappedStruct_desc(ctx, field, obj)
   364  
   365  		default:
   366  			panic("unknown field " + strconv.Quote(field.Name))
   367  		}
   368  	}
   369  	out.Dispatch()
   370  	if invalids > 0 {
   371  		return graphql.Null
   372  	}
   373  	return out
   374  }
   375  
   376  // endregion **************************** object.gotpl ****************************
   377  
   378  // region    ***************************** type.gotpl *****************************
   379  
   380  func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedMap(ctx context.Context, sel ast.SelectionSet, v WrappedMap) graphql.Marshaler {
   381  	if v == nil {
   382  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   383  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   384  		}
   385  		return graphql.Null
   386  	}
   387  	return ec._WrappedMap(ctx, sel, v)
   388  }
   389  
   390  func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (otherpkg.Scalar, error) {
   391  	tmp, err := graphql.UnmarshalString(v)
   392  	res := otherpkg.Scalar(tmp)
   393  	return res, graphql.ErrorOnPath(ctx, err)
   394  }
   395  
   396  func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v otherpkg.Scalar) graphql.Marshaler {
   397  	res := graphql.MarshalString(string(v))
   398  	if res == graphql.Null {
   399  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   400  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   401  		}
   402  	}
   403  	return res
   404  }
   405  
   406  func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedSlice(ctx context.Context, sel ast.SelectionSet, v WrappedSlice) graphql.Marshaler {
   407  	if v == nil {
   408  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   409  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   410  		}
   411  		return graphql.Null
   412  	}
   413  	return ec._WrappedSlice(ctx, sel, v)
   414  }
   415  
   416  func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v WrappedStruct) graphql.Marshaler {
   417  	return ec._WrappedStruct(ctx, sel, &v)
   418  }
   419  
   420  func (ec *executionContext) marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v *WrappedStruct) graphql.Marshaler {
   421  	if v == nil {
   422  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   423  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   424  		}
   425  		return graphql.Null
   426  	}
   427  	return ec._WrappedStruct(ctx, sel, v)
   428  }
   429  
   430  func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (*otherpkg.Scalar, error) {
   431  	if v == nil {
   432  		return nil, nil
   433  	}
   434  	tmp, err := graphql.UnmarshalString(v)
   435  	res := otherpkg.Scalar(tmp)
   436  	return &res, graphql.ErrorOnPath(ctx, err)
   437  }
   438  
   439  func (ec *executionContext) marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v *otherpkg.Scalar) graphql.Marshaler {
   440  	if v == nil {
   441  		return graphql.Null
   442  	}
   443  	res := graphql.MarshalString(string(*v))
   444  	return res
   445  }
   446  
   447  // endregion ***************************** type.gotpl *****************************