github.com/operandinc/gqlgen@v0.16.1/codegen/testserver/followschema/slices.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  
     9  	"github.com/operandinc/gqlgen/graphql"
    10  	"github.com/vektah/gqlparser/v2/ast"
    11  )
    12  
    13  // region    ************************** generated!.gotpl **************************
    14  
    15  // endregion ************************** generated!.gotpl **************************
    16  
    17  // region    ***************************** args.gotpl *****************************
    18  
    19  // endregion ***************************** args.gotpl *****************************
    20  
    21  // region    ************************** directives.gotpl **************************
    22  
    23  // endregion ************************** directives.gotpl **************************
    24  
    25  // region    **************************** field.gotpl *****************************
    26  
    27  func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
    28  	defer func() {
    29  		if r := recover(); r != nil {
    30  			ec.Error(ctx, ec.Recover(ctx, r))
    31  			ret = graphql.Null
    32  		}
    33  	}()
    34  	fc := &graphql.FieldContext{
    35  		Object:     "Slices",
    36  		Field:      field,
    37  		Args:       nil,
    38  		IsMethod:   false,
    39  		IsResolver: false,
    40  	}
    41  
    42  	ctx = graphql.WithFieldContext(ctx, fc)
    43  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    44  		ctx = rctx // use context from middleware stack in children
    45  		return obj.Test1, nil
    46  	})
    47  
    48  	if resTmp == nil {
    49  		return graphql.Null
    50  	}
    51  	res := resTmp.([]*string)
    52  	fc.Result = res
    53  	return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res)
    54  }
    55  
    56  func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
    57  	defer func() {
    58  		if r := recover(); r != nil {
    59  			ec.Error(ctx, ec.Recover(ctx, r))
    60  			ret = graphql.Null
    61  		}
    62  	}()
    63  	fc := &graphql.FieldContext{
    64  		Object:     "Slices",
    65  		Field:      field,
    66  		Args:       nil,
    67  		IsMethod:   false,
    68  		IsResolver: false,
    69  	}
    70  
    71  	ctx = graphql.WithFieldContext(ctx, fc)
    72  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
    73  		ctx = rctx // use context from middleware stack in children
    74  		return obj.Test2, nil
    75  	})
    76  
    77  	if resTmp == nil {
    78  		return graphql.Null
    79  	}
    80  	res := resTmp.([]string)
    81  	fc.Result = res
    82  	return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res)
    83  }
    84  
    85  func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
    86  	defer func() {
    87  		if r := recover(); r != nil {
    88  			ec.Error(ctx, ec.Recover(ctx, r))
    89  			ret = graphql.Null
    90  		}
    91  	}()
    92  	fc := &graphql.FieldContext{
    93  		Object:     "Slices",
    94  		Field:      field,
    95  		Args:       nil,
    96  		IsMethod:   false,
    97  		IsResolver: false,
    98  	}
    99  
   100  	ctx = graphql.WithFieldContext(ctx, fc)
   101  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   102  		ctx = rctx // use context from middleware stack in children
   103  		return obj.Test3, nil
   104  	})
   105  
   106  	if resTmp == nil {
   107  		if !graphql.HasFieldError(ctx, fc) {
   108  			ec.Errorf(ctx, "must not be null")
   109  		}
   110  		return graphql.Null
   111  	}
   112  	res := resTmp.([]*string)
   113  	fc.Result = res
   114  	return ec.marshalNString2ᚕᚖstring(ctx, field.Selections, res)
   115  }
   116  
   117  func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) {
   118  	defer func() {
   119  		if r := recover(); r != nil {
   120  			ec.Error(ctx, ec.Recover(ctx, r))
   121  			ret = graphql.Null
   122  		}
   123  	}()
   124  	fc := &graphql.FieldContext{
   125  		Object:     "Slices",
   126  		Field:      field,
   127  		Args:       nil,
   128  		IsMethod:   false,
   129  		IsResolver: false,
   130  	}
   131  
   132  	ctx = graphql.WithFieldContext(ctx, fc)
   133  	resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
   134  		ctx = rctx // use context from middleware stack in children
   135  		return obj.Test4, nil
   136  	})
   137  
   138  	if resTmp == nil {
   139  		if !graphql.HasFieldError(ctx, fc) {
   140  			ec.Errorf(ctx, "must not be null")
   141  		}
   142  		return graphql.Null
   143  	}
   144  	res := resTmp.([]string)
   145  	fc.Result = res
   146  	return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res)
   147  }
   148  
   149  // endregion **************************** field.gotpl *****************************
   150  
   151  // region    **************************** input.gotpl *****************************
   152  
   153  // endregion **************************** input.gotpl *****************************
   154  
   155  // region    ************************** interface.gotpl ***************************
   156  
   157  // endregion ************************** interface.gotpl ***************************
   158  
   159  // region    **************************** object.gotpl ****************************
   160  
   161  var slicesImplementors = []string{"Slices"}
   162  
   163  func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, obj *Slices) graphql.Marshaler {
   164  	fields := graphql.CollectFields(ec.OperationContext, sel, slicesImplementors)
   165  	out := graphql.NewFieldSet(fields)
   166  	var invalids uint32
   167  	for i, field := range fields {
   168  		switch field.Name {
   169  		case "__typename":
   170  			out.Values[i] = graphql.MarshalString("Slices")
   171  		case "test1":
   172  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   173  				return ec._Slices_test1(ctx, field, obj)
   174  			}
   175  
   176  			out.Values[i] = innerFunc(ctx)
   177  
   178  		case "test2":
   179  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   180  				return ec._Slices_test2(ctx, field, obj)
   181  			}
   182  
   183  			out.Values[i] = innerFunc(ctx)
   184  
   185  		case "test3":
   186  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   187  				return ec._Slices_test3(ctx, field, obj)
   188  			}
   189  
   190  			out.Values[i] = innerFunc(ctx)
   191  
   192  			if out.Values[i] == graphql.Null {
   193  				invalids++
   194  			}
   195  		case "test4":
   196  			innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
   197  				return ec._Slices_test4(ctx, field, obj)
   198  			}
   199  
   200  			out.Values[i] = innerFunc(ctx)
   201  
   202  			if out.Values[i] == graphql.Null {
   203  				invalids++
   204  			}
   205  		default:
   206  			panic("unknown field " + strconv.Quote(field.Name))
   207  		}
   208  	}
   209  	out.Dispatch()
   210  	if invalids > 0 {
   211  		return graphql.Null
   212  	}
   213  	return out
   214  }
   215  
   216  // endregion **************************** object.gotpl ****************************
   217  
   218  // region    ***************************** type.gotpl *****************************
   219  
   220  func (ec *executionContext) unmarshalNBytes2ᚕbyte(ctx context.Context, v interface{}) ([]byte, error) {
   221  	res, err := UnmarshalBytes(v)
   222  	return res, graphql.ErrorOnPath(ctx, err)
   223  }
   224  
   225  func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.SelectionSet, v []byte) graphql.Marshaler {
   226  	if v == nil {
   227  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   228  			ec.Errorf(ctx, "must not be null")
   229  		}
   230  		return graphql.Null
   231  	}
   232  	res := MarshalBytes(v)
   233  	if res == graphql.Null {
   234  		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
   235  			ec.Errorf(ctx, "must not be null")
   236  		}
   237  	}
   238  	return res
   239  }
   240  
   241  func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler {
   242  	if v == nil {
   243  		return graphql.Null
   244  	}
   245  	return ec._Slices(ctx, sel, v)
   246  }
   247  
   248  // endregion ***************************** type.gotpl *****************************