feat(frontend): warn about a high-cost stored GraphQL query [INFP-739]

Draft
FA
6d ago
+430-0

Stacked pull requests for INFP-739. Each one is based on the one before it:

  1. #11004: Store the cost level of each stored GraphQL query. Base: #11003 (fac/graphql-query-cost-impl-rrake), which adds the query cost estimate.
  2. #11005 (this pull request): Warn about a high-cost stored query in the web UI.
  3. #11006: Limit or skip the artifact renders of high-cost queries.

Why: the page of a stored query does not show its cost

With the previous pull request, a stored query has a cost level, but its page shows the level only as one attribute in the Details card. A user who opens a high-cost stored query does not view that one run can read a large part of the database, or which fields read the most rows.

Not in this pull request:

  • Moving the raw cost_estimate JSON behind the Extra toggle of the Details card. This needs display: extra on the attribute in the backend schema. The JSON is also the only place that shows the figures of a low query and the reason of an unknown one.
  • A note for the unknown level. Every stored query has it until the first refresh of the statistics, and a query with a mutation keeps it, so the note would show on most pages with nothing the user can do.

Warning on the page of a high-cost stored query

  • When cost_level is high, the details page of a stored query shows a warning with these values from cost_estimate:
    • the worst-case and expected database rows of one run, and the limit they were compared with
    • when the statistics were computed
    • the fields with the most worst-case database rows
    • how many fields have no estimate, when some have none
  • The warning links to the section "View the cost level of a stored query" of the documentation.
  • A low or unknown level shows no warning.
  • The list of stored queries shows a Cost Level column, from the attribute that the previous pull request adds.

How to review

  1. frontend/app/src/entities/nodes/object/ui/CoreGraphQLQuery/graphql-query-cost-warning.tsx and its schema frontend/app/src/entities/nodes/object/domain/model/graphql-query-cost.ts
  2. graphql-query-details.tsx, which places the warning on the page

How to test

cd frontend/app && npx vitest run src/entities/nodes/object/ui/CoreGraphQLQuery/graphql-query-cost-warning.test.tsx

The end-to-end tests in tests/e2e/objects/CoreGraphQLQuery/test_graphql_query_cost_warning.py refresh the statistics, then check the warning on the page of a high-cost stored query and the Cost Level column of the list.

Local results: the 6 Vitest tests passed, the frontend checks passed, and the 2 end-to-end tests passed against an image built from this branch.

Impact and rollout

  • Backward compatibility: no backend change and no new setting.

Documentation: query-cost.mdx describes the Cost Level column and the warning. Changelog entry: +graphql-query-cost-warning.added.md.

Checklist

  • Tests added/updated
  • Changelog entry added
  • External docs updated (if user-facing or ops-facing change)
  • Internal .md docs updated (internal knowledge and AI code tools knowledge)
  • I have reviewed AI generated content

Assisted-by: opsmill-dev-pr 0.2.0

šŸ¤– Generated with Claude Code