520 lines
16 KiB
Go
520 lines
16 KiB
Go
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
|
|
|
|
package generated
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"strconv"
|
|
"sync/atomic"
|
|
|
|
"github.com/99designs/gqlgen/graphql"
|
|
"github.com/99designs/gqlgen/graphql/introspection"
|
|
"github.com/vektah/gqlparser/v2/ast"
|
|
)
|
|
|
|
// region ************************** generated!.gotpl **************************
|
|
|
|
type MutationResolver interface {
|
|
Login(ctx context.Context, username string, email string) (bool, error)
|
|
Logout(ctx context.Context) (bool, error)
|
|
}
|
|
type QueryResolver interface {
|
|
HeartBeat(ctx context.Context) (bool, error)
|
|
}
|
|
|
|
// endregion ************************** generated!.gotpl **************************
|
|
|
|
// region ***************************** args.gotpl *****************************
|
|
|
|
func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
|
var err error
|
|
args := map[string]interface{}{}
|
|
arg0, err := ec.field_Mutation_login_argsUsername(ctx, rawArgs)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
args["username"] = arg0
|
|
arg1, err := ec.field_Mutation_login_argsEmail(ctx, rawArgs)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
args["email"] = arg1
|
|
return args, nil
|
|
}
|
|
func (ec *executionContext) field_Mutation_login_argsUsername(
|
|
ctx context.Context,
|
|
rawArgs map[string]interface{},
|
|
) (string, error) {
|
|
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("username"))
|
|
if tmp, ok := rawArgs["username"]; ok {
|
|
return ec.unmarshalNString2string(ctx, tmp)
|
|
}
|
|
|
|
var zeroVal string
|
|
return zeroVal, nil
|
|
}
|
|
|
|
func (ec *executionContext) field_Mutation_login_argsEmail(
|
|
ctx context.Context,
|
|
rawArgs map[string]interface{},
|
|
) (string, error) {
|
|
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
|
if tmp, ok := rawArgs["email"]; ok {
|
|
return ec.unmarshalNString2string(ctx, tmp)
|
|
}
|
|
|
|
var zeroVal string
|
|
return zeroVal, nil
|
|
}
|
|
|
|
func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
|
var err error
|
|
args := map[string]interface{}{}
|
|
arg0, err := ec.field_Query___type_argsName(ctx, rawArgs)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
args["name"] = arg0
|
|
return args, nil
|
|
}
|
|
func (ec *executionContext) field_Query___type_argsName(
|
|
ctx context.Context,
|
|
rawArgs map[string]interface{},
|
|
) (string, error) {
|
|
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
|
|
if tmp, ok := rawArgs["name"]; ok {
|
|
return ec.unmarshalNString2string(ctx, tmp)
|
|
}
|
|
|
|
var zeroVal string
|
|
return zeroVal, nil
|
|
}
|
|
|
|
// endregion ***************************** args.gotpl *****************************
|
|
|
|
// region ************************** directives.gotpl **************************
|
|
|
|
// endregion ************************** directives.gotpl **************************
|
|
|
|
// region **************************** field.gotpl *****************************
|
|
|
|
func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
|
fc, err := ec.fieldContext_Mutation_login(ctx, field)
|
|
if err != nil {
|
|
return graphql.Null
|
|
}
|
|
ctx = graphql.WithFieldContext(ctx, fc)
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
ec.Error(ctx, ec.Recover(ctx, r))
|
|
ret = graphql.Null
|
|
}
|
|
}()
|
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
|
ctx = rctx // use context from middleware stack in children
|
|
return ec.resolvers.Mutation().Login(rctx, fc.Args["username"].(string), fc.Args["email"].(string))
|
|
})
|
|
if err != nil {
|
|
ec.Error(ctx, err)
|
|
return graphql.Null
|
|
}
|
|
if resTmp == nil {
|
|
if !graphql.HasFieldError(ctx, fc) {
|
|
ec.Errorf(ctx, "must not be null")
|
|
}
|
|
return graphql.Null
|
|
}
|
|
res := resTmp.(bool)
|
|
fc.Result = res
|
|
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
|
}
|
|
|
|
func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
|
fc = &graphql.FieldContext{
|
|
Object: "Mutation",
|
|
Field: field,
|
|
IsMethod: true,
|
|
IsResolver: true,
|
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
|
return nil, errors.New("field of type Boolean does not have child fields")
|
|
},
|
|
}
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
err = ec.Recover(ctx, r)
|
|
ec.Error(ctx, err)
|
|
}
|
|
}()
|
|
ctx = graphql.WithFieldContext(ctx, fc)
|
|
if fc.Args, err = ec.field_Mutation_login_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
|
ec.Error(ctx, err)
|
|
return fc, err
|
|
}
|
|
return fc, nil
|
|
}
|
|
|
|
func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
|
fc, err := ec.fieldContext_Mutation_logout(ctx, field)
|
|
if err != nil {
|
|
return graphql.Null
|
|
}
|
|
ctx = graphql.WithFieldContext(ctx, fc)
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
ec.Error(ctx, ec.Recover(ctx, r))
|
|
ret = graphql.Null
|
|
}
|
|
}()
|
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
|
ctx = rctx // use context from middleware stack in children
|
|
return ec.resolvers.Mutation().Logout(rctx)
|
|
})
|
|
if err != nil {
|
|
ec.Error(ctx, err)
|
|
return graphql.Null
|
|
}
|
|
if resTmp == nil {
|
|
if !graphql.HasFieldError(ctx, fc) {
|
|
ec.Errorf(ctx, "must not be null")
|
|
}
|
|
return graphql.Null
|
|
}
|
|
res := resTmp.(bool)
|
|
fc.Result = res
|
|
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
|
}
|
|
|
|
func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
|
fc = &graphql.FieldContext{
|
|
Object: "Mutation",
|
|
Field: field,
|
|
IsMethod: true,
|
|
IsResolver: true,
|
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
|
return nil, errors.New("field of type Boolean does not have child fields")
|
|
},
|
|
}
|
|
return fc, nil
|
|
}
|
|
|
|
func (ec *executionContext) _Query_heartBeat(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
|
fc, err := ec.fieldContext_Query_heartBeat(ctx, field)
|
|
if err != nil {
|
|
return graphql.Null
|
|
}
|
|
ctx = graphql.WithFieldContext(ctx, fc)
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
ec.Error(ctx, ec.Recover(ctx, r))
|
|
ret = graphql.Null
|
|
}
|
|
}()
|
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
|
ctx = rctx // use context from middleware stack in children
|
|
return ec.resolvers.Query().HeartBeat(rctx)
|
|
})
|
|
if err != nil {
|
|
ec.Error(ctx, err)
|
|
return graphql.Null
|
|
}
|
|
if resTmp == nil {
|
|
if !graphql.HasFieldError(ctx, fc) {
|
|
ec.Errorf(ctx, "must not be null")
|
|
}
|
|
return graphql.Null
|
|
}
|
|
res := resTmp.(bool)
|
|
fc.Result = res
|
|
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
|
}
|
|
|
|
func (ec *executionContext) fieldContext_Query_heartBeat(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
|
fc = &graphql.FieldContext{
|
|
Object: "Query",
|
|
Field: field,
|
|
IsMethod: true,
|
|
IsResolver: true,
|
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
|
return nil, errors.New("field of type Boolean does not have child fields")
|
|
},
|
|
}
|
|
return fc, nil
|
|
}
|
|
|
|
func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
|
fc, err := ec.fieldContext_Query___type(ctx, field)
|
|
if err != nil {
|
|
return graphql.Null
|
|
}
|
|
ctx = graphql.WithFieldContext(ctx, fc)
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
ec.Error(ctx, ec.Recover(ctx, r))
|
|
ret = graphql.Null
|
|
}
|
|
}()
|
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
|
ctx = rctx // use context from middleware stack in children
|
|
return ec.introspectType(fc.Args["name"].(string))
|
|
})
|
|
if err != nil {
|
|
ec.Error(ctx, err)
|
|
return graphql.Null
|
|
}
|
|
if resTmp == nil {
|
|
return graphql.Null
|
|
}
|
|
res := resTmp.(*introspection.Type)
|
|
fc.Result = res
|
|
return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res)
|
|
}
|
|
|
|
func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
|
fc = &graphql.FieldContext{
|
|
Object: "Query",
|
|
Field: field,
|
|
IsMethod: true,
|
|
IsResolver: false,
|
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
|
switch field.Name {
|
|
case "kind":
|
|
return ec.fieldContext___Type_kind(ctx, field)
|
|
case "name":
|
|
return ec.fieldContext___Type_name(ctx, field)
|
|
case "description":
|
|
return ec.fieldContext___Type_description(ctx, field)
|
|
case "fields":
|
|
return ec.fieldContext___Type_fields(ctx, field)
|
|
case "interfaces":
|
|
return ec.fieldContext___Type_interfaces(ctx, field)
|
|
case "possibleTypes":
|
|
return ec.fieldContext___Type_possibleTypes(ctx, field)
|
|
case "enumValues":
|
|
return ec.fieldContext___Type_enumValues(ctx, field)
|
|
case "inputFields":
|
|
return ec.fieldContext___Type_inputFields(ctx, field)
|
|
case "ofType":
|
|
return ec.fieldContext___Type_ofType(ctx, field)
|
|
case "specifiedByURL":
|
|
return ec.fieldContext___Type_specifiedByURL(ctx, field)
|
|
}
|
|
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
|
|
},
|
|
}
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
err = ec.Recover(ctx, r)
|
|
ec.Error(ctx, err)
|
|
}
|
|
}()
|
|
ctx = graphql.WithFieldContext(ctx, fc)
|
|
if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
|
ec.Error(ctx, err)
|
|
return fc, err
|
|
}
|
|
return fc, nil
|
|
}
|
|
|
|
func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
|
fc, err := ec.fieldContext_Query___schema(ctx, field)
|
|
if err != nil {
|
|
return graphql.Null
|
|
}
|
|
ctx = graphql.WithFieldContext(ctx, fc)
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
ec.Error(ctx, ec.Recover(ctx, r))
|
|
ret = graphql.Null
|
|
}
|
|
}()
|
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
|
ctx = rctx // use context from middleware stack in children
|
|
return ec.introspectSchema()
|
|
})
|
|
if err != nil {
|
|
ec.Error(ctx, err)
|
|
return graphql.Null
|
|
}
|
|
if resTmp == nil {
|
|
return graphql.Null
|
|
}
|
|
res := resTmp.(*introspection.Schema)
|
|
fc.Result = res
|
|
return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res)
|
|
}
|
|
|
|
func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
|
fc = &graphql.FieldContext{
|
|
Object: "Query",
|
|
Field: field,
|
|
IsMethod: true,
|
|
IsResolver: false,
|
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
|
switch field.Name {
|
|
case "description":
|
|
return ec.fieldContext___Schema_description(ctx, field)
|
|
case "types":
|
|
return ec.fieldContext___Schema_types(ctx, field)
|
|
case "queryType":
|
|
return ec.fieldContext___Schema_queryType(ctx, field)
|
|
case "mutationType":
|
|
return ec.fieldContext___Schema_mutationType(ctx, field)
|
|
case "subscriptionType":
|
|
return ec.fieldContext___Schema_subscriptionType(ctx, field)
|
|
case "directives":
|
|
return ec.fieldContext___Schema_directives(ctx, field)
|
|
}
|
|
return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name)
|
|
},
|
|
}
|
|
return fc, nil
|
|
}
|
|
|
|
// endregion **************************** field.gotpl *****************************
|
|
|
|
// region **************************** input.gotpl *****************************
|
|
|
|
// endregion **************************** input.gotpl *****************************
|
|
|
|
// region ************************** interface.gotpl ***************************
|
|
|
|
// endregion ************************** interface.gotpl ***************************
|
|
|
|
// region **************************** object.gotpl ****************************
|
|
|
|
var mutationImplementors = []string{"Mutation"}
|
|
|
|
func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
|
|
fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
|
|
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
|
|
Object: "Mutation",
|
|
})
|
|
|
|
out := graphql.NewFieldSet(fields)
|
|
deferred := make(map[string]*graphql.FieldSet)
|
|
for i, field := range fields {
|
|
innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
|
|
Object: field.Name,
|
|
Field: field,
|
|
})
|
|
|
|
switch field.Name {
|
|
case "__typename":
|
|
out.Values[i] = graphql.MarshalString("Mutation")
|
|
case "login":
|
|
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
|
return ec._Mutation_login(ctx, field)
|
|
})
|
|
if out.Values[i] == graphql.Null {
|
|
out.Invalids++
|
|
}
|
|
case "logout":
|
|
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
|
return ec._Mutation_logout(ctx, field)
|
|
})
|
|
if out.Values[i] == graphql.Null {
|
|
out.Invalids++
|
|
}
|
|
default:
|
|
panic("unknown field " + strconv.Quote(field.Name))
|
|
}
|
|
}
|
|
out.Dispatch(ctx)
|
|
if out.Invalids > 0 {
|
|
return graphql.Null
|
|
}
|
|
|
|
atomic.AddInt32(&ec.deferred, int32(len(deferred)))
|
|
|
|
for label, dfs := range deferred {
|
|
ec.processDeferredGroup(graphql.DeferredGroup{
|
|
Label: label,
|
|
Path: graphql.GetPath(ctx),
|
|
FieldSet: dfs,
|
|
Context: ctx,
|
|
})
|
|
}
|
|
|
|
return out
|
|
}
|
|
|
|
var queryImplementors = []string{"Query"}
|
|
|
|
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
|
|
fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
|
|
ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
|
|
Object: "Query",
|
|
})
|
|
|
|
out := graphql.NewFieldSet(fields)
|
|
deferred := make(map[string]*graphql.FieldSet)
|
|
for i, field := range fields {
|
|
innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
|
|
Object: field.Name,
|
|
Field: field,
|
|
})
|
|
|
|
switch field.Name {
|
|
case "__typename":
|
|
out.Values[i] = graphql.MarshalString("Query")
|
|
case "heartBeat":
|
|
field := field
|
|
|
|
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
ec.Error(ctx, ec.Recover(ctx, r))
|
|
}
|
|
}()
|
|
res = ec._Query_heartBeat(ctx, field)
|
|
if res == graphql.Null {
|
|
atomic.AddUint32(&fs.Invalids, 1)
|
|
}
|
|
return res
|
|
}
|
|
|
|
rrm := func(ctx context.Context) graphql.Marshaler {
|
|
return ec.OperationContext.RootResolverMiddleware(ctx,
|
|
func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
|
}
|
|
|
|
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) })
|
|
case "__type":
|
|
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
|
return ec._Query___type(ctx, field)
|
|
})
|
|
case "__schema":
|
|
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
|
return ec._Query___schema(ctx, field)
|
|
})
|
|
default:
|
|
panic("unknown field " + strconv.Quote(field.Name))
|
|
}
|
|
}
|
|
out.Dispatch(ctx)
|
|
if out.Invalids > 0 {
|
|
return graphql.Null
|
|
}
|
|
|
|
atomic.AddInt32(&ec.deferred, int32(len(deferred)))
|
|
|
|
for label, dfs := range deferred {
|
|
ec.processDeferredGroup(graphql.DeferredGroup{
|
|
Label: label,
|
|
Path: graphql.GetPath(ctx),
|
|
FieldSet: dfs,
|
|
Context: ctx,
|
|
})
|
|
}
|
|
|
|
return out
|
|
}
|
|
|
|
// endregion **************************** object.gotpl ****************************
|
|
|
|
// region ***************************** type.gotpl *****************************
|
|
|
|
// endregion ***************************** type.gotpl *****************************
|