Available since Router 0.185.0
Prerequisites
To generate query plans, you will need the following:- Router executable (version 0.185.0 or later)
- Router execution configuration file
- Queries folder
- Output folder
wgc:
wgc router compose.
For detailed steps, follow the first two steps outlined here: Mastering Local Development for GraphQL Federation.
Generating query plans
In the following example, we assume the following directory structure:Report generation
The report structure changed since Router 0.189.0
-print-report option to generate a report in addition to the individual query plan files. The report will be saved in the plans folder as report.json and will follow this structure:
-print-per-file=false.
The error field on the first level will contain a value only if there is an error that is not directly related to a single plan (eg: timeout error, missing or corrupted router config).
The fields inside timings, added since router version 0.265.0, contains the time taken (in nanoseconds) for each phase of the query planning process. If you use the values to track performance over time, make sure to run the command in similar conditions to get comparable results and to allow some variance in the data.
Fail on planning error
If you want the command to exit with an error if at least one query fails to be planned, you can use the option-fail-on-error.
Output Format
By default the query plan format is text based, but you can view the json version by using-print-format json
Engine execution settings
Some engine settings change the shape of the generated plans. To reproduce the plans of a router running with those settings, enable them on the command as well:-enable-multi-fetchmatchesengine.enable_multi_fetch, merging entity fetches to the same subgraph that execute in the same wave into a single batched request.-enable-schedule-fetchesmatchesengine.enable_schedule_fetches, replacing the wave-based fetch organizers with the dependency-aware fetch scheduler.