Skip to content

GraphQL Timing

Module: Magenx_GraphQlTiming · no settings, no new fields

Adds a Server-Timing header to every GraphQL response with the time Magento spent handling the request:

Server-Timing: magento-app;desc="magento dispatch";dur=42.0

When a GraphQL request is slow, this tells you whether Magento or the network is the cause. With GRAPHQL_PROFILE on, the storefront’s /api/graphql proxy merges this value into the Server-Timing header the browser sees (DevTools > Network > Timing). The difference between the proxy’s proxy-upstream value and magento-app is the network hop.

The header is cheap and has no side effects, so it is safe to leave on.

Profile a request

  1. A developer turns on the storefront's profiling flag.
  2. A browser request passes through the proxy; the back office response carries its processing time.
  3. The proxy merges it with its upstream time; developer tools show both. Upstream minus processing = network.

These always hold:

  • The header never changes response body or status.
  • One request's timing is never influenced by another.
  • Duration = (end − start) × 1000, one decimal.
SituationWhat happens
Two requests in one long-running worker.Each header shows its own duration.
Processing throws an error.Error passes on; no header.
  • Per-operation or per-query timing.
  • Timing for non-API traffic.
  • Storing or exporting metrics.
Terminal window
composer require magenxcommerce/module-graph-ql-timing
bin/magento module:enable Magenx_GraphQlTiming
bin/magento setup:upgrade
bin/magento setup:di:compile # production mode only
bin/magento cache:flush

For timing per resolver and per database query, use Magento’s built-in profiler:

Terminal window
bin/magento dev:profiler:enable html
TermMeaning
Processing timeWall-clock time from the API request entering the back office to the response being built.
Server-TimingStandard HTTP response header carrying named timing metrics.
Upstream timeTime the storefront proxy waited for the back office.