limits

package
v1.0.1 Latest Latest
Warning

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

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

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

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