Documentation
¶
Overview ¶
Package limits provides reusable gqlgen extensions for enforcing abuse-resilient GraphQL execution limits.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DepthLimit ¶
type DepthLimit struct {
Func func(ctx context.Context, opCtx *graphql.OperationContext) int
}
DepthLimit enforces a maximum selection depth for a GraphQL operation.
Depth is defined as the maximum number of nested field selections from the operation root. If a query exceeds the configured limit, a 422 status code will be returned by gqlgen.
func FixedDepthLimit ¶
func FixedDepthLimit(limit int) *DepthLimit
FixedDepthLimit sets a depth limit that does not change. A limit <= 0 disables depth enforcement.
func (DepthLimit) ExtensionName ¶
func (d DepthLimit) ExtensionName() string
ExtensionName implements graphql.HandlerExtension.
func (DepthLimit) MutateOperationContext ¶
func (d DepthLimit) MutateOperationContext(ctx context.Context, opCtx *graphql.OperationContext) *gqlerror.Error
MutateOperationContext implements graphql.OperationContextMutator.
func (*DepthLimit) Validate ¶
func (d *DepthLimit) Validate(_ graphql.ExecutableSchema) error
Validate implements graphql.HandlerExtension.
type DepthStats ¶
DepthStats contains computed depth information for the active GraphQL operation.
func GetDepthStats ¶
func GetDepthStats(ctx context.Context) *DepthStats
GetDepthStats returns DepthStats for the active operation, if available.