github.com/senomas/gqlgen@v0.17.11-0.20220626120754-9aee61b0716a/codegen/testserver/followschema/defaults.generated.go (about)

     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  
    11  	"github.com/99designs/gqlgen/graphql"
    12  	"github.com/vektah/gqlparser/v2/ast"
    13  )
    14  
    15  // region    ************************** generated!.gotpl **************************
    16  
    17  type MutationResolver interface {
    18  	DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error)
    19  	UpdateSomething(ctx context.Context, input SpecialInput) (string, error)
    20  	UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error)
    21  }
    22  
    23  // endregion ************************** generated!.gotpl **************************
    24  
    25  // region    ***************************** args.gotpl *****************************
    26  
    27  func (ec *executionContext) field_Mutation_defaultInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
    28  	var err error
    29  	args := map[string]interface{}{}
    30  	var arg0 DefaultInput
    31  	if tmp, ok := rawArgs["input"]; ok {
    32  		ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
    33  		arg0, err = ec.unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx, tmp)
    34  		if err != nil {
    35  			return nil, err
    36  		}
    37  	}
    38  	args["input"] = arg0
    39  	return args, nil
    40  }
    41  
    42  func (ec *executionContext) field_Mutation_updatePtrToPtr_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
    43  	var err error
    44  	args := map[string]interface{}{}
    45  	var arg0 UpdatePtrToPtrOuter
    46  	if tmp, ok := rawArgs["input"]; ok {
    47  		ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
    48  		arg0, err = ec.unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrOuter(ctx, tmp)
    49  		if err != nil {
    50  			return nil, err
    51  		}
    52  	}
    53  	args["input"] = arg0
    54  	return args, nil
    55  }
    56  
    57  func (ec *executionContext) field_Mutation_updateSomething_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
    58  	var err error
    59  	args := map[string]interface{}{}
    60  	var arg0 SpecialInput
    61  	if tmp, ok := rawArgs["input"]; ok {
    62  		ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
    63  		arg0, err = ec.unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSpecialInput(ctx, tmp)
    64  		if err != nil {
    65  			return nil, err
    66  		}
    67  	}
    68  	args["input"] = arg0
    69  	return args, nil
    70  }
    71  
    72  // endregion ***************************** args.gotpl *****************************
    73  
    74  // region    ************************** directives.gotpl **************************
    75  
    76  // endregion ************************** directives.gotpl **************************
    77  
    78  // region    **************************** field.gotpl *****************************
    79  
    80  func (ec *executionContext) _DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) {
    81  	fc, err := ec.fieldContext_DefaultParametersMirror_falsyBoolean(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.FalsyBoolean, nil
    95  	})
    96  
    97  	if resTmp == nil {
    98  		return graphql.Null
    99  	}
   100  	res := resTmp.(*bool)
   101  	fc.Result = res
   102  	return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
   103  }
   104  
   105  func (ec *executionContext) fieldContext_DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   106  	fc = &graphql.FieldContext{
   107  		Object:     "DefaultParametersMirror",
   108  		Field:      field,
   109  		IsMethod:   false,
   110  		IsResolver: false,
   111  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   112  			return nil, errors.New("field of type Boolean does not have child fields")
   113  		},
   114  	}
   115  	return fc, nil
   116  }
   117  
   118  func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) {
   119  	fc, err := ec.fieldContext_DefaultParametersMirror_truthyBoolean(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.TruthyBoolean, nil
   133  	})
   134  
   135  	if resTmp == nil {
   136  		return graphql.Null
   137  	}
   138  	res := resTmp.(*bool)
   139  	fc.Result = res
   140  	return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
   141  }
   142  
   143  func (ec *executionContext) fieldContext_DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   144  	fc = &graphql.FieldContext{
   145  		Object:     "DefaultParametersMirror",
   146  		Field:      field,
   147  		IsMethod:   false,
   148  		IsResolver: false,
   149  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   150  			return nil, errors.New("field of type Boolean does not have child fields")
   151  		},
   152  	}
   153  	return fc, nil
   154  }
   155  
   156  func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
   157  	fc, err := ec.fieldContext_Mutation_defaultInput(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, nil, func(rctx context.Context) (interface{}, error) {
   169  		ctx = rctx // use context from middleware stack in children
   170  		return ec.resolvers.Mutation().DefaultInput(rctx, fc.Args["input"].(DefaultInput))
   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.(*DefaultParametersMirror)
   180  	fc.Result = res
   181  	return ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx, field.Selections, res)
   182  }
   183  
   184  func (ec *executionContext) fieldContext_Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   185  	fc = &graphql.FieldContext{
   186  		Object:     "Mutation",
   187  		Field:      field,
   188  		IsMethod:   true,
   189  		IsResolver: true,
   190  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   191  			switch field.Name {
   192  			case "falsyBoolean":
   193  				return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field)
   194  			case "truthyBoolean":
   195  				return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field)
   196  			}
   197  			return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name)
   198  		},
   199  	}
   200  	defer func() {
   201  		if r := recover(); r != nil {
   202  			err = ec.Recover(ctx, r)
   203  			ec.Error(ctx, err)
   204  		}
   205  	}()
   206  	ctx = graphql.WithFieldContext(ctx, fc)
   207  	if fc.Args, err = ec.field_Mutation_defaultInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
   208  		ec.Error(ctx, err)
   209  		return
   210  	}
   211  	return fc, nil
   212  }
   213  
   214  func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
   215  	fc, err := ec.fieldContext_Mutation_updateSomething(ctx, field)
   216  	if err != nil {
   217  		return graphql.Null
   218  	}
   219  	ctx = graphql.WithFieldContext(ctx, fc)
   220  	defer func() {
   221  		if r := recover(); r != nil {
   222  			ec.Error(ctx, ec.Recover(ctx, r))
   223  			ret = graphql.Null
   224  		}
   225  	}()
   226  	resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
   227  		ctx = rctx // use context from middleware stack in children
   228  		return ec.resolvers.Mutation().UpdateSomething(rctx, fc.Args["input"].(SpecialInput))
   229  	})
   230  
   231  	if resTmp == nil {
   232  		if !graphql.HasFieldError(ctx, fc) {
   233  			ec.Errorf(ctx, "must not be null")
   234  		}
   235  		return graphql.Null
   236  	}
   237  	res := resTmp.(string)
   238  	fc.Result = res
   239  	return ec.marshalNString2string(ctx, field.Selections, res)
   240  }
   241  
   242  func (ec *executionContext) fieldContext_Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   243  	fc = &graphql.FieldContext{
   244  		Object:     "Mutation",
   245  		Field:      field,
   246  		IsMethod:   true,
   247  		IsResolver: true,
   248  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   249  			return nil, errors.New("field of type String does not have child fields")
   250  		},
   251  	}
   252  	defer func() {
   253  		if r := recover(); r != nil {
   254  			err = ec.Recover(ctx, r)
   255  			ec.Error(ctx, err)
   256  		}
   257  	}()
   258  	ctx = graphql.WithFieldContext(ctx, fc)
   259  	if fc.Args, err = ec.field_Mutation_updateSomething_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
   260  		ec.Error(ctx, err)
   261  		return
   262  	}
   263  	return fc, nil
   264  }
   265  
   266  func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
   267  	fc, err := ec.fieldContext_Mutation_updatePtrToPtr(ctx, field)
   268  	if err != nil {
   269  		return graphql.Null
   270  	}
   271  	ctx = graphql.WithFieldContext(ctx, fc)
   272  	defer func() {
   273  		if r := recover(); r != nil {
   274  			ec.Error(ctx, ec.Recover(ctx, r))
   275  			ret = graphql.Null
   276  		}
   277  	}()
   278  	resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
   279  		ctx = rctx // use context from middleware stack in children
   280  		return ec.resolvers.Mutation().UpdatePtrToPtr(rctx, fc.Args["input"].(UpdatePtrToPtrOuter))
   281  	})
   282  
   283  	if resTmp == nil {
   284  		if !graphql.HasFieldError(ctx, fc) {
   285  			ec.Errorf(ctx, "must not be null")
   286  		}
   287  		return graphql.Null
   288  	}
   289  	res := resTmp.(*PtrToPtrOuter)
   290  	fc.Result = res
   291  	return ec.marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx, field.Selections, res)
   292  }
   293  
   294  func (ec *executionContext) fieldContext_Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
   295  	fc = &graphql.FieldContext{
   296  		Object:     "Mutation",
   297  		Field:      field,
   298  		IsMethod:   true,
   299  		IsResolver: true,
   300  		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
   301  			switch field.Name {
   302  			case "name":
   303  				return ec.fieldContext_PtrToPtrOuter_name(ctx, field)
   304  			case "inner":
   305  				return ec.fieldContext_PtrToPtrOuter_inner(ctx, field)
   306  			case "stupidInner":
   307  				return ec.fieldContext_PtrToPtrOuter_stupidInner(ctx, field)
   308  			}
   309  			return nil, fmt.Errorf("no field named %q was found under type PtrToPtrOuter", field.Name)
   310  		},
   311  	}
   312  	defer func() {
   313  		if r := recover(); r != nil {
   314  			err = ec.Recover(ctx, r)
   315  			ec.Error(ctx, err)
   316  		}
   317  	}()
   318  	ctx = graphql.WithFieldContext(ctx, fc)
   319  	if fc.Args, err = ec.field_Mutation_updatePtrToPtr_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
   320  		ec.Error(ctx, err)
   321  		return
   322  	}
   323  	return fc, nil
   324  }
   325  
   326  // endregion **************************** field.gotpl *****************************
   327  
   328  // region    **************************** input.gotpl *****************************
   329  
   330  func (ec *executionContext) unmarshalInputDefaultInput(ctx context.Context, obj interface{}) (DefaultInput, error) {
   331  	var it DefaultInput
   332  	asMap := map[string]interface{}{}
   333  	for k, v := range obj.(map[string]interface{}) {
   334  		asMap[k] = v
   335  	}
   336  
   337  	if _, present := asMap["falsyBoolean"]; !present {
   338  		asMap["falsyBoolean"] = false
   339  	}
   340  	if _, present := asMap["truthyBoolean"]; !present {
   341  		asMap["truthyBoolean"] = true
   342  	}
   343  
   344  	for k, v := range asMap {
   345  		switch k {
   346  		case "falsyBoolean":
   347  			var err error
   348  
   349  			ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean"))
   350  			it.FalsyBoolean, err = ec.unmarshalOBoolean2ᚖbool(ctx, v)
   351  			if err != nil {
   352  				return it, err
   353  			}
   354  		case "truthyBoolean":
   355  			var err error
   356  
   357  			ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean"))
   358  			it.TruthyBoolean, err = ec.unmarshalOBoolean2ᚖbool(ctx, v)
   359  			if err != nil {
   360  				return it, err
   361  			}
   362  		}
   363  	}
   364  
   365  	return it, nil
   366  }
   367  
   368  // endregion **************************** input.gotpl *****************************
   369  
   370  // region    ************************** interface.gotpl ***************************
   371  
   372  // endregion ************************** interface.gotpl ***************************
   373  
   374  // region    **************************** object.gotpl ****************************
   375  
   376  var defaultParametersMirrorImplementors = []string{"DefaultParametersMirror"}
   377  
   378  func (ec *executionContext) _DefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, obj *DefaultParametersMirror) graphql.Marshaler {
   379  	fields := graphql.CollectFields(ec.OperationContext, sel, defaultParametersMirrorImplementors)
   380  	out := graphql.NewFieldSet(fields)
   381  	var invalids uint32
   382  	for i, field := range fields {
   383  		switch field.Name {
   384  		case "__typename":
   385  			out.Values[i] = graphql.MarshalString("DefaultParametersMirror")
   386  		case "falsyBoolean":
   387  
   388  			out.Values[i] = ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj)
   389  
   390  		case "truthyBoolean":
   391  
   392  			out.Values[i] = ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj)
   393  
   394  		default:
   395  			panic("unknown field " + strconv.Quote(field.Name))
   396  		}
   397  	}
   398  	out.Dispatch()
   399  	if invalids > 0 {
   400  		return graphql.Null
   401  	}
   402  	return out
   403  }
   404  
   405  var mutationImplementors = []string{"Mutation"}
   406  
   407  func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
   408  	fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
   409  	ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
   410  		Object: "Mutation",
   411  	})
   412  
   413  	out := graphql.NewFieldSet(fields)
   414  	var invalids uint32
   415  	for i, field := range fields {
   416  		innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
   417  			Object: field.Name,
   418  			Field:  field,
   419  		})
   420  
   421  		switch field.Name {
   422  		case "__typename":
   423  			out.Values[i] = graphql.MarshalString("Mutation")
   424  		case "defaultInput":
   425  
   426  			out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
   427  				return ec._Mutation_defaultInput(ctx, field)
   428  			})
   429  
   430  			if out.Values[i] == graphql.Null {
   431  				invalids++
   432  			}
   433  		case "updateSomething":
   434  
   435  			out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
   436  				return ec._Mutation_updateSomething(ctx, field)
   437  			})
   438  
   439  			if out.Values[i] == graphql.Null {
   440  				invalids++
   441  			}
   442  		case "updatePtrToPtr":
   443  
   444  			out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
   445  				return ec._Mutation_updatePtrToPtr(ctx, field)
   446  			})
   447  
   448  			if out.Values[i] == graphql.Null {
   449  				invalids++
   450  			}
   451  		default:
   452  			panic("unknown field " + strconv.Quote(field.Name))
   453  		}
   454  	}
   455  	out.Dispatch()
   456  	if invalids > 0 {
   457  		return graphql.Null
   458  	}
   459  	return out
   460  }
   461  
   462  // endregion **************************** object.gotpl ****************************
   463  
   464  // region    ***************************** type.gotpl *****************************
   465  
   466  func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx context.Context, v interface{}) (DefaultInput, error) {
   467  	res, err := ec.unmarshalInputDefaultInput(ctx, v)
   468  	return res, graphql.ErrorOnPath(ctx, err)
   469  }
   470  
   471  func (ec *executionContext) marshalNDefaultParametersMirror2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v DefaultParametersMirror) graphql.Marshaler {
   472  	return ec._DefaultParametersMirror(ctx, sel, &v)
   473  }
   474  
   475  func (ec *executionContext) marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v *DefaultParametersMirror) graphql.Marshaler {
   476  	if v == nil {
   477  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   478  			ec.Errorf(ctx, "the requested element is null which the schema does not allow")
   479  		}
   480  		return graphql.Null
   481  	}
   482  	return ec._DefaultParametersMirror(ctx, sel, v)
   483  }
   484  
   485  // endregion ***************************** type.gotpl *****************************