NAME

GraphQL::Houtou::Validation::DepthLimit - query depth limit validator

SYNOPSIS

use GraphQL::Houtou::Validation::DepthLimit qw(check_query_depth);

my $ast = GraphQL::Houtou::parse($query_string);
my @errors = check_query_depth($ast, max_depth => 10);
if (@errors) {
    return { data => undef, errors => \@errors };
}

DESCRIPTION

Validates that a parsed GraphQL document does not exceed a maximum field nesting depth. Fragments and inline fragments are followed without adding depth themselves; only concrete field selections increment the depth counter.

The default maximum depth is 10. Pass max_depth => undef to disable the check entirely.

FUNCTIONS

check_query_depth($ast, %opts)

Accepts a parsed AST (arrayref of definition nodes as returned by GraphQL::Houtou::parse()) and optional named arguments:

max_depth

Maximum allowed nesting depth. Defaults to 15. Set to undef to disable.

Returns a list of error hashrefs (each with a message key) — empty list means the document is within the limit.

SEE ALSO

GraphQL::Houtou