limits

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package limits provides reusable gqlgen extensions for enforcing abuse-resilient GraphQL execution limits.

Index

Constants

View Source
const AutomationMaxDepth = 4

AutomationMaxDepth is the GraphQL selection-depth ceiling for agent and CLI automation tokens. Query complexity, parser-token, and pagination limits remain the primary breadth and resource-consumption controls.

Variables

This section is empty.

Functions

func RequestDepthLimit added in v1.6.4

func RequestDepthLimit(ctx context.Context, configuredDepth int) int

RequestDepthLimit resolves the depth limit for the authenticated caller. Human and anonymous callers retain the operator-configured limit; automation callers retain a bounded limit even when the general limit is disabled.

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

type DepthStats struct {
	Depth      int
	DepthLimit int
}

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.

Jump to

Keyboard shortcuts

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