BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Waxwing · Budget an expanded GraphQL field plan

Check the depth and weighted resolver cost of an expanded GraphQL field plan.

Budget an expanded GraphQL field plan

A flat query can cost more than a deep one when list fields fan out. Evaluate expanded cost and depth independently. The plan is only two levels deep, but its visit-weighted work is 17 against a budget of 15.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-waxwing.git
cd blyx-waxwing
blyxc native-run project.blyx -- "1,2,2" "1,3,2" "1,4,2" 3 15

API and return values

Returns [admitted, maximum depth, total work, costliest field index]. Supply resolved aliases, fragments and list visit estimates from your parser. Invalid input returns an empty vector.

ArgumentAccepted input
depthsVector of: nonnegative exact integer
unitsVector of: nonnegative exact integer
visitsVector of: nonnegative exact integer
max_depthpositive exact integer
budgetnonnegative exact integer

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
0
2
17
1
Open in the full playground →

Practice

Change depths = [1, 2], units = [2, 3], visits = [1, 2], max_depth = 2.0, budget = 8.0. Predict the result, then run the program.

Hint

Returns [admitted, maximum depth, total work, costliest field index]. Supply resolved aliases, fragments and list visit estimates from your parser.

Worked solution

The result vector is [1, 2, 8, 1]. Compare its fields with the return layout in the API section.

Find

    let depths = [1, 2, 2];

Replace with

    let depths = [1, 2];

Find

    let units = [1, 3, 2];

Replace with

    let units = [2, 3];

Find

    let visits = [1, 4, 2];

Replace with

    let visits = [1, 2];

Find

    let max_depth = 3.0;

Replace with

    let max_depth = 2.0;

Find

    let budget = 15.0;

Replace with

    let budget = 8.0;

Output after the change

1
2
8
1