2024-11-01 14:25:30 +00:00
|
|
|
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
|
|
|
|
|
|
|
|
package generated
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"sync/atomic"
|
|
|
|
|
|
|
|
"github.com/99designs/gqlgen/graphql"
|
|
|
|
"github.com/99designs/gqlgen/graphql/introspection"
|
|
|
|
gqlparser "github.com/vektah/gqlparser/v2"
|
|
|
|
"github.com/vektah/gqlparser/v2/ast"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
|
|
|
|
func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {
|
|
|
|
return &executableSchema{
|
|
|
|
schema: cfg.Schema,
|
|
|
|
resolvers: cfg.Resolvers,
|
|
|
|
directives: cfg.Directives,
|
|
|
|
complexity: cfg.Complexity,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Schema *ast.Schema
|
|
|
|
Resolvers ResolverRoot
|
|
|
|
Directives DirectiveRoot
|
|
|
|
Complexity ComplexityRoot
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResolverRoot interface {
|
|
|
|
Mutation() MutationResolver
|
|
|
|
Query() QueryResolver
|
|
|
|
}
|
|
|
|
|
|
|
|
type DirectiveRoot struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type ComplexityRoot struct {
|
2024-11-01 17:49:56 +00:00
|
|
|
AuthUser struct {
|
2024-11-17 16:58:29 +00:00
|
|
|
Email func(childComplexity int) int
|
|
|
|
ID func(childComplexity int) int
|
|
|
|
Name func(childComplexity int) int
|
|
|
|
RoleID func(childComplexity int) int
|
2024-11-01 17:49:56 +00:00
|
|
|
}
|
|
|
|
|
2024-11-01 14:25:30 +00:00
|
|
|
Mutation struct {
|
2024-11-17 16:58:29 +00:00
|
|
|
AccountLogin func(childComplexity int, email string, pwd string) int
|
|
|
|
AccountLogout func(childComplexity int) int
|
|
|
|
AccountVerifyEmail func(childComplexity int, token *string) int
|
2024-11-01 14:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Query struct {
|
2024-11-15 16:12:15 +00:00
|
|
|
Me func(childComplexity int) int
|
2024-11-01 14:25:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type executableSchema struct {
|
|
|
|
schema *ast.Schema
|
|
|
|
resolvers ResolverRoot
|
|
|
|
directives DirectiveRoot
|
|
|
|
complexity ComplexityRoot
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *executableSchema) Schema() *ast.Schema {
|
|
|
|
if e.schema != nil {
|
|
|
|
return e.schema
|
|
|
|
}
|
|
|
|
return parsedSchema
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {
|
|
|
|
ec := executionContext{nil, e, 0, 0, nil}
|
|
|
|
_ = ec
|
|
|
|
switch typeName + "." + field {
|
|
|
|
|
2024-11-01 17:49:56 +00:00
|
|
|
case "AuthUser.email":
|
|
|
|
if e.complexity.AuthUser.Email == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.complexity.AuthUser.Email(childComplexity), true
|
|
|
|
|
|
|
|
case "AuthUser.id":
|
|
|
|
if e.complexity.AuthUser.ID == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.complexity.AuthUser.ID(childComplexity), true
|
|
|
|
|
2024-11-17 16:58:29 +00:00
|
|
|
case "AuthUser.name":
|
|
|
|
if e.complexity.AuthUser.Name == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.complexity.AuthUser.Name(childComplexity), true
|
|
|
|
|
2024-11-01 17:49:56 +00:00
|
|
|
case "AuthUser.roleID":
|
|
|
|
if e.complexity.AuthUser.RoleID == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.complexity.AuthUser.RoleID(childComplexity), true
|
|
|
|
|
2024-11-17 16:58:29 +00:00
|
|
|
case "Mutation.accountLogin":
|
|
|
|
if e.complexity.Mutation.AccountLogin == nil {
|
2024-11-01 14:25:30 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2024-11-17 16:58:29 +00:00
|
|
|
args, err := ec.field_Mutation_accountLogin_args(context.TODO(), rawArgs)
|
2024-11-01 14:25:30 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, false
|
|
|
|
}
|
|
|
|
|
2024-11-17 16:58:29 +00:00
|
|
|
return e.complexity.Mutation.AccountLogin(childComplexity, args["email"].(string), args["pwd"].(string)), true
|
|
|
|
|
|
|
|
case "Mutation.accountLogout":
|
|
|
|
if e.complexity.Mutation.AccountLogout == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.complexity.Mutation.AccountLogout(childComplexity), true
|
2024-11-01 14:25:30 +00:00
|
|
|
|
2024-11-17 16:58:29 +00:00
|
|
|
case "Mutation.accountVerifyEmail":
|
|
|
|
if e.complexity.Mutation.AccountVerifyEmail == nil {
|
2024-11-01 14:25:30 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2024-11-17 16:58:29 +00:00
|
|
|
args, err := ec.field_Mutation_accountVerifyEmail_args(context.TODO(), rawArgs)
|
|
|
|
if err != nil {
|
|
|
|
return 0, false
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.complexity.Mutation.AccountVerifyEmail(childComplexity, args["token"].(*string)), true
|
2024-11-01 14:25:30 +00:00
|
|
|
|
2024-11-01 17:49:56 +00:00
|
|
|
case "Query.me":
|
|
|
|
if e.complexity.Query.Me == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.complexity.Query.Me(childComplexity), true
|
|
|
|
|
2024-11-01 14:25:30 +00:00
|
|
|
}
|
|
|
|
return 0, false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
2024-11-15 16:12:15 +00:00
|
|
|
opCtx := graphql.GetOperationContext(ctx)
|
|
|
|
ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)}
|
2024-11-01 14:25:30 +00:00
|
|
|
inputUnmarshalMap := graphql.BuildUnmarshalerMap()
|
|
|
|
first := true
|
|
|
|
|
2024-11-15 16:12:15 +00:00
|
|
|
switch opCtx.Operation.Operation {
|
2024-11-01 14:25:30 +00:00
|
|
|
case ast.Query:
|
|
|
|
return func(ctx context.Context) *graphql.Response {
|
|
|
|
var response graphql.Response
|
|
|
|
var data graphql.Marshaler
|
|
|
|
if first {
|
|
|
|
first = false
|
|
|
|
ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap)
|
2024-11-15 16:12:15 +00:00
|
|
|
data = ec._Query(ctx, opCtx.Operation.SelectionSet)
|
2024-11-01 14:25:30 +00:00
|
|
|
} else {
|
|
|
|
if atomic.LoadInt32(&ec.pendingDeferred) > 0 {
|
|
|
|
result := <-ec.deferredResults
|
|
|
|
atomic.AddInt32(&ec.pendingDeferred, -1)
|
|
|
|
data = result.Result
|
|
|
|
response.Path = result.Path
|
|
|
|
response.Label = result.Label
|
|
|
|
response.Errors = result.Errors
|
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
data.MarshalGQL(&buf)
|
|
|
|
response.Data = buf.Bytes()
|
|
|
|
if atomic.LoadInt32(&ec.deferred) > 0 {
|
|
|
|
hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0
|
|
|
|
response.HasNext = &hasNext
|
|
|
|
}
|
|
|
|
|
|
|
|
return &response
|
|
|
|
}
|
|
|
|
case ast.Mutation:
|
|
|
|
return func(ctx context.Context) *graphql.Response {
|
|
|
|
if !first {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
first = false
|
|
|
|
ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap)
|
2024-11-15 16:12:15 +00:00
|
|
|
data := ec._Mutation(ctx, opCtx.Operation.SelectionSet)
|
2024-11-01 14:25:30 +00:00
|
|
|
var buf bytes.Buffer
|
|
|
|
data.MarshalGQL(&buf)
|
|
|
|
|
|
|
|
return &graphql.Response{
|
|
|
|
Data: buf.Bytes(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type executionContext struct {
|
|
|
|
*graphql.OperationContext
|
|
|
|
*executableSchema
|
|
|
|
deferred int32
|
|
|
|
pendingDeferred int32
|
|
|
|
deferredResults chan graphql.DeferredResult
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) {
|
|
|
|
atomic.AddInt32(&ec.pendingDeferred, 1)
|
|
|
|
go func() {
|
|
|
|
ctx := graphql.WithFreshResponseContext(dg.Context)
|
|
|
|
dg.FieldSet.Dispatch(ctx)
|
|
|
|
ds := graphql.DeferredResult{
|
|
|
|
Path: dg.Path,
|
|
|
|
Label: dg.Label,
|
|
|
|
Result: dg.FieldSet,
|
|
|
|
Errors: graphql.GetErrors(ctx),
|
|
|
|
}
|
|
|
|
// null fields should bubble up
|
|
|
|
if dg.FieldSet.Invalids > 0 {
|
|
|
|
ds.Result = graphql.Null
|
|
|
|
}
|
|
|
|
ec.deferredResults <- ds
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ec *executionContext) introspectSchema() (*introspection.Schema, error) {
|
|
|
|
if ec.DisableIntrospection {
|
|
|
|
return nil, errors.New("introspection disabled")
|
|
|
|
}
|
|
|
|
return introspection.WrapSchema(ec.Schema()), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ec *executionContext) introspectType(name string) (*introspection.Type, error) {
|
|
|
|
if ec.DisableIntrospection {
|
|
|
|
return nil, errors.New("introspection disabled")
|
|
|
|
}
|
|
|
|
return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var sources = []*ast.Source{
|
2024-11-15 16:12:15 +00:00
|
|
|
{Name: "../account.graphql", Input: `extend type Mutation {
|
2024-11-17 16:58:29 +00:00
|
|
|
"""
|
|
|
|
Verify email token
|
|
|
|
"""
|
|
|
|
accountVerifyEmail(token: String): Boolean!
|
|
|
|
|
|
|
|
"""
|
|
|
|
User account login
|
|
|
|
"""
|
|
|
|
accountLogin(email: String!, pwd: String!): AuthUser!
|
|
|
|
|
|
|
|
"""
|
|
|
|
User account logout
|
|
|
|
"""
|
|
|
|
accountLogout: Boolean!
|
2024-11-01 14:25:30 +00:00
|
|
|
}
|
2024-11-01 17:49:56 +00:00
|
|
|
|
|
|
|
extend type Query {
|
|
|
|
me: AuthUser
|
|
|
|
}
|
|
|
|
|
|
|
|
type AuthUser {
|
2024-11-17 16:58:29 +00:00
|
|
|
id: UID!
|
2024-11-01 17:49:56 +00:00
|
|
|
email: String!
|
2024-11-17 16:58:29 +00:00
|
|
|
name: String!
|
2024-11-01 17:49:56 +00:00
|
|
|
roleID: Int!
|
|
|
|
}
|
2024-11-01 14:25:30 +00:00
|
|
|
`, BuiltIn: false},
|
2024-11-15 16:12:15 +00:00
|
|
|
{Name: "../root.graphql", Input: `# GraphQL schema example
|
2024-11-01 14:25:30 +00:00
|
|
|
#
|
|
|
|
# https://gqlgen.com/getting-started/
|
|
|
|
|
|
|
|
type Mutation
|
|
|
|
|
2024-11-15 16:12:15 +00:00
|
|
|
type Query
|
2024-11-01 14:25:30 +00:00
|
|
|
|
2024-11-17 16:58:29 +00:00
|
|
|
scalar UID
|
|
|
|
|
|
|
|
scalar Int64
|
|
|
|
|
2024-11-01 14:25:30 +00:00
|
|
|
"""
|
|
|
|
Maps a Time GraphQL scalar to a Go time.Time struct.
|
|
|
|
"""
|
|
|
|
scalar Time
|
|
|
|
|
|
|
|
"""
|
|
|
|
type Map(Go type: map[string]interface{})
|
|
|
|
"""
|
|
|
|
scalar Map
|
|
|
|
|
|
|
|
"""
|
|
|
|
Go type interface{}
|
|
|
|
"""
|
|
|
|
scalar Any
|
2024-11-17 16:58:29 +00:00
|
|
|
|
2024-11-01 14:25:30 +00:00
|
|
|
scalar Void
|
|
|
|
|
|
|
|
"""
|
|
|
|
directive to map Go type
|
|
|
|
type User @goModel(model: "github.com/my/app/models.User") {
|
|
|
|
id: ID! @goField(name: "todoId")
|
|
|
|
name: String!
|
|
|
|
@goField(forceResolver: true)
|
|
|
|
@goTag(key: "xorm", value: "-")
|
|
|
|
@goTag(key: "yaml")
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
directive @goModel(
|
|
|
|
model: String
|
|
|
|
models: [String!]
|
|
|
|
forceGenerate: Boolean
|
|
|
|
) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
|
|
|
|
|
|
|
|
"""
|
|
|
|
directive to map Go type
|
|
|
|
"""
|
|
|
|
directive @goField(
|
|
|
|
forceResolver: Boolean
|
|
|
|
name: String
|
|
|
|
omittable: Boolean
|
|
|
|
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
|
|
|
|
|
|
|
|
directive @goTag(key: String!, value: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
|
|
|
|
`, BuiltIn: false},
|
|
|
|
}
|
|
|
|
var parsedSchema = gqlparser.MustLoadSchema(sources...)
|