graphql

package
v0.0.0-...-a7b4bc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAccountOrPasswordInvalid = gql.Error("account or password invalid", gql.WithErrCode("AccountOrPasswordInvalid"))

ErrAccountOrPasswordInvalid 账号或密码无效

View Source
var ErrVerifyCodeInvalid = gql.Error("verify code invalid", gql.WithErrCode("VerifyCodeInvalid"))

ErrVerifyCodeInvalid 验证码无效

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func NewSchema

func NewSchema(logger log.Logger, db *ent.Database, client *ent.Client, accountUseCase *biz.AccountUseCase) graphql.ExecutableSchema

NewSchema creates a graphql executable schema.

Types

type ComplexityRoot

type ComplexityRoot struct {
	Account struct {
		ID       func(childComplexity int) int
		Nickname func(childComplexity int) int
	}

	LoginReply struct {
		Exp   func(childComplexity int) int
		Token func(childComplexity int) int
		User  func(childComplexity int) int
	}

	Mutation struct {
		CreatePermission func(childComplexity int, input ent.CreatePermissionInput) int
		CreateRole       func(childComplexity int, input ent.CreateRoleInput) int
		CreateUser       func(childComplexity int, input ent.CreateUserInput) int
		DeletePermission func(childComplexity int, id int) int
		DeleteRole       func(childComplexity int, id int) int
		ForgetPassword   func(childComplexity int, email string, code string, password string) int
		ResetPassword    func(childComplexity int, oldPassword string, password string) int
		UpdatePermission func(childComplexity int, id int, input ent.UpdatePermissionInput) int
		UpdateProfile    func(childComplexity int, input model.UpdateProfileInput) int
		UpdateRole       func(childComplexity int, id int, input ent.UpdateRoleInput) int
		UpdateUser       func(childComplexity int, id int, input ent.UpdateUserInput) int
	}

	OperationLog struct {
		Context   func(childComplexity int) int
		CreatedAt func(childComplexity int) int
		ID        func(childComplexity int) int
		Type      func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
		User      func(childComplexity int) int
		UserID    func(childComplexity int) int
	}

	OperationLogConnection struct {
		Edges      func(childComplexity int) int
		Nodes      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	OperationLogEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	PageInfo struct {
		EndCursor       func(childComplexity int) int
		HasNextPage     func(childComplexity int) int
		HasPreviousPage func(childComplexity int) int
		StartCursor     func(childComplexity int) int
	}

	Permission struct {
		Attrs         func(childComplexity int) int
		Children      func(childComplexity int) int
		ChildrenCount func(childComplexity int) int
		CreatedAt     func(childComplexity int) int
		Desc          func(childComplexity int) int
		ID            func(childComplexity int) int
		Key           func(childComplexity int) int
		Name          func(childComplexity int) int
		Parent        func(childComplexity int) int
		ParentID      func(childComplexity int) int
		Path          func(childComplexity int) int
		Sort          func(childComplexity int) int
		Type          func(childComplexity int) int
		UpdatedAt     func(childComplexity int) int
	}

	PermissionConnection struct {
		Edges      func(childComplexity int) int
		Nodes      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	PermissionEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	Query struct {
		Captcha        func(childComplexity int) int
		Login          func(childComplexity int, email string, password string, captchaID *string, captchaValue *string) int
		Node           func(childComplexity int, id int) int
		Nodes          func(childComplexity int, ids []int) int
		OperationLogs  func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.OperationLogOrder, where *ent.OperationLogWhereInput) int
		Permissions    func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.PermissionOrder, where *ent.PermissionWhereInput) int
		Profile        func(childComplexity int) int
		Refresh        func(childComplexity int) int
		Roles          func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.RoleOrder, where *ent.RoleWhereInput) int
		SendVerifyCode func(childComplexity int, email string, verifyType model.VerifyCodeType) int
		Users          func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int
	}

	Role struct {
		CreatedAt   func(childComplexity int) int
		ID          func(childComplexity int) int
		Name        func(childComplexity int) int
		Permissions func(childComplexity int) int
		Sort        func(childComplexity int) int
		UpdatedAt   func(childComplexity int) int
	}

	RoleConnection struct {
		Edges      func(childComplexity int) int
		Nodes      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	RoleEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	User struct {
		Avatar      func(childComplexity int) int
		CreatedAt   func(childComplexity int) int
		Email       func(childComplexity int) int
		ID          func(childComplexity int) int
		IsAdmin     func(childComplexity int) int
		Nickname    func(childComplexity int) int
		Permissions func(childComplexity int) int
		RoleCount   func(childComplexity int) int
		Roles       func(childComplexity int) int
		Status      func(childComplexity int) int
		UpdatedAt   func(childComplexity int) int
	}

	UserConnection struct {
		Edges      func(childComplexity int) int
		Nodes      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	UserEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	CaptchaReply struct {
		Captcha func(childComplexity int) int
		ID      func(childComplexity int) int
	}
}

type Config

type Config struct {
	Schema     *ast.Schema
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
	Disabled      func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error)
	HasPermission func(ctx context.Context, obj any, next graphql.Resolver, key string) (res any, err error)
	Login         func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error)
}

type MutationResolver

type MutationResolver interface {
	ResetPassword(ctx context.Context, oldPassword string, password string) (bool, error)
	ForgetPassword(ctx context.Context, email string, code string, password string) (bool, error)
	UpdateProfile(ctx context.Context, input model.UpdateProfileInput) (*ent.User, error)
	CreateUser(ctx context.Context, input ent.CreateUserInput) (*ent.User, error)
	UpdateUser(ctx context.Context, id int, input ent.UpdateUserInput) (*ent.User, error)
	CreateRole(ctx context.Context, input ent.CreateRoleInput) (*ent.Role, error)
	UpdateRole(ctx context.Context, id int, input ent.UpdateRoleInput) (*ent.Role, error)
	DeleteRole(ctx context.Context, id int) (bool, error)
	CreatePermission(ctx context.Context, input ent.CreatePermissionInput) (*ent.Permission, error)
	UpdatePermission(ctx context.Context, id int, input ent.UpdatePermissionInput) (*ent.Permission, error)
	DeletePermission(ctx context.Context, id int) (bool, error)
}

type PermissionResolver

type PermissionResolver interface {
	ChildrenCount(ctx context.Context, obj *ent.Permission) (int, error)
}

type QueryResolver

type QueryResolver interface {
	Node(ctx context.Context, id int) (ent.Noder, error)
	Nodes(ctx context.Context, ids []int) ([]ent.Noder, error)
	OperationLogs(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.OperationLogOrder, where *ent.OperationLogWhereInput) (*ent.OperationLogConnection, error)
	Permissions(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.PermissionOrder, where *ent.PermissionWhereInput) (*ent.PermissionConnection, error)
	Roles(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.RoleOrder, where *ent.RoleWhereInput) (*ent.RoleConnection, error)
	Users(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserConnection, error)
	Login(ctx context.Context, email string, password string, captchaID *string, captchaValue *string) (*model.LoginReply, error)
	Profile(ctx context.Context) (*ent.User, error)
	Refresh(ctx context.Context) (*model.LoginReply, error)
	SendVerifyCode(ctx context.Context, email string, verifyType model.VerifyCodeType) (bool, error)
	Captcha(ctx context.Context) (*model.CaptchaReply, error)
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation returns MutationResolver implementation.

func (*Resolver) Permission

func (r *Resolver) Permission() PermissionResolver

Permission returns PermissionResolver implementation.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query returns QueryResolver implementation.

func (*Resolver) User

func (r *Resolver) User() UserResolver

User returns UserResolver implementation.

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Permission() PermissionResolver
	Query() QueryResolver
	User() UserResolver
}

type UserResolver

type UserResolver interface {
	RoleCount(ctx context.Context, obj *ent.User) (int, error)
	Permissions(ctx context.Context, obj *ent.User) ([]*ent.Permission, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL