gql

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const (
	FieldCount = "count"
	FieldItems = "items"
)
View Source
const CustomErrorKey string = "custom"

Variables

View Source
var ErrAccessDenied = Error("access denied", WithErrCode("AccessDenied"))

ErrAccessDenied 拒绝访问,无角色或身份

View Source
var ErrDeprecated = Error("deprecated", WithErrCode("Deprecated"))

ErrDeprecated 方法已弃用

View Source
var ErrDisabled = Error("disabled", WithErrCode("Disabled"))

ErrDisabled 已禁用

View Source
var ErrNoPermission = Error("no permission", WithErrCode("NoPermission"))

ErrNoPermission 无权限

View Source
var ErrNotFound = Error("data not found", WithErrCode("NotFound"))

ErrNotFound 数据不存在

View Source
var ErrUnauthorized = Error("unauthorized", WithErrCode("Unauthorized"))

ErrUnauthorized 未授权

Functions

func BatchFunc

func BatchFunc(fn LoaderFunc) dataloader.BatchFunc

func ContainsCountField added in v0.1.6

func ContainsCountField(ctx context.Context) bool

ContainsCountField 包含 count 字段

func ContainsField

func ContainsField(ctx context.Context, field string) bool

ContainsField 包含字段

func ContainsItemsField added in v0.1.6

func ContainsItemsField(ctx context.Context) bool

ContainsItemsField 包含 items 字段

func Error

func Error(message string, opts ...ErrOption) *gqlerror.Error

func ErrorPresenter

func ErrorPresenter(logger log.Logger) func(ctx context.Context, err error) *gqlerror.Error

func EveryFields

func EveryFields(ctx context.Context, fields ...string) bool

EveryFields 每个字段都包含

func FillDefault added in v0.1.2

func FillDefault(keys dataloader.Keys, result map[dataloader.Key]any, value any) map[dataloader.Key]any

func FillDefaultByKey added in v0.1.2

func FillDefaultByKey(keys dataloader.Keys, result map[dataloader.Key]any, fn func(dataloader.Key) any) map[dataloader.Key]any

func MarshalerString added in v0.2.6

func MarshalerString(s string) graphql.Marshaler

func MarshalerUint8 added in v0.2.6

func MarshalerUint8(s uint8) graphql.Marshaler

func NewServer added in v0.2.4

func NewServer(es graphql.ExecutableSchema) *handler.Server

func OffsetLimit

func OffsetLimit(page *int, size *int, opts ...PageOption) (offset int, limit int)

func SomeFields

func SomeFields(ctx context.Context, fields ...string) bool

SomeFields 包含任意字段

func SomeWhere

func SomeWhere(items ...any) bool

func ToInts

func ToInts(keys dataloader.Keys) []int

func ToStringKey

func ToStringKey(id any) dataloader.Key

func TraceAroundOperations added in v0.2.4

func TraceAroundOperations(middleware graphql.OperationMiddleware) graphql.OperationMiddleware

func TraceAroundResponses added in v0.2.4

func TraceAroundResponses(middleware graphql.ResponseMiddleware) graphql.ResponseMiddleware

func UnmarshalerString added in v0.2.6

func UnmarshalerString[T ~string](v any) (T, error)

func UnmarshalerUint8 added in v0.2.6

func UnmarshalerUint8[T ~uint8](v any) (T, error)

func ValidateError added in v0.1.2

func ValidateError(message string) *gqlerror.Error

Types

type ErrOption

type ErrOption func(*ErrOptions)

func WithErrCode

func WithErrCode(code string) ErrOption

type ErrOptions

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

type LoaderFunc

type LoaderFunc func(ctx context.Context, keys dataloader.Keys) (map[dataloader.Key]any, error)

type PageOption added in v0.2.2

type PageOption func(*pageOption)

func WithDefaultSize added in v0.2.2

func WithDefaultSize(defaultSize int) PageOption

func WithMaxItems added in v0.2.2

func WithMaxItems(maxItems int) PageOption

func WithMaxSize added in v0.2.2

func WithMaxSize(maxSize int) PageOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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