Documentation
¶
Index ¶
- Constants
- Variables
- func BatchFunc(fn LoaderFunc) dataloader.BatchFunc
- func ContainsCountField(ctx context.Context) bool
- func ContainsField(ctx context.Context, field string) bool
- func ContainsItemsField(ctx context.Context) bool
- func Error(message string, opts ...ErrOption) *gqlerror.Error
- func ErrorPresenter(logger log.Logger) func(ctx context.Context, err error) *gqlerror.Error
- func EveryFields(ctx context.Context, fields ...string) bool
- func FillDefault(keys dataloader.Keys, result map[dataloader.Key]any, value any) map[dataloader.Key]any
- func FillDefaultByKey(keys dataloader.Keys, result map[dataloader.Key]any, ...) map[dataloader.Key]any
- func MarshalerString(s string) graphql.Marshaler
- func MarshalerUint8(s uint8) graphql.Marshaler
- func NewServer(es graphql.ExecutableSchema) *handler.Server
- func OffsetLimit(page *int, size *int, opts ...PageOption) (offset int, limit int)
- func SomeFields(ctx context.Context, fields ...string) bool
- func SomeWhere(items ...any) bool
- func ToInts(keys dataloader.Keys) []int
- func ToStringKey(id any) dataloader.Key
- func TraceAroundOperations(middleware graphql.OperationMiddleware) graphql.OperationMiddleware
- func TraceAroundResponses(middleware graphql.ResponseMiddleware) graphql.ResponseMiddleware
- func UnmarshalerString[T ~string](v any) (T, error)
- func UnmarshalerUint8[T ~uint8](v any) (T, error)
- func ValidateError(message string) *gqlerror.Error
- type ErrOption
- type ErrOptions
- type LoaderFunc
- type PageOption
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 数据不存在
ErrUnauthorized 未授权
Functions ¶
func BatchFunc ¶
func BatchFunc(fn LoaderFunc) dataloader.BatchFunc
func ContainsCountField ¶ added in v0.1.6
ContainsCountField 包含 count 字段
func ContainsItemsField ¶ added in v0.1.6
ContainsItemsField 包含 items 字段
func ErrorPresenter ¶
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 MarshalerUint8 ¶ added in v0.2.6
func OffsetLimit ¶
func OffsetLimit(page *int, size *int, opts ...PageOption) (offset int, limit int)
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 UnmarshalerUint8 ¶ added in v0.2.6
func ValidateError ¶ added in v0.1.2
Types ¶
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
Click to show internal directories.
Click to hide internal directories.