Skip to content

Add infrahubctl graphql query-report command#976

Merged
ogenstad merged 3 commits into
developfrom
pog-graphql-query-report-ifc-2236
Jun 8, 2026
Merged

Add infrahubctl graphql query-report command#976
ogenstad merged 3 commits into
developfrom
pog-graphql-query-report-ifc-2236

Conversation

@ogenstad

@ogenstad ogenstad commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Why

Adds a new subcommand to infrahubctl for infrahubctl graphql query-report, it's to allow users to check a query either from a .infrahub.yml file or by specifying the name of a query that exists in Infrahub and returning a query report. For now the only entry in the report is that users can see if the query can be used for unique targets for artifact definitions.

Example output

blue on  main [⇡] via 🐍 v3.12.12 (infrahub-sdk) on ☁️   took 2s
❯ /Users/patrick/Code/opsmill/infrahub/.venv/bin/infrahubctl graphql query-report gen
Query 'gen' (local: generators/gen.gql)
Targets unique nodes: false — all artifacts for the definition will be regenerated on any relevant node change.

blue on  main [⇡] via 🐍 v3.12.12 (infrahub-sdk) on ☁️
❯ /Users/patrick/Code/opsmill/infrahub/.venv/bin/infrahubctl graphql query-report character
Query 'character' (local: checks/character.gql)
Targets unique nodes: true — Infrahub will limit artifact regeneration to changed nodes only.

What changed

  • New command for infrahubctl that uses GraphQL query introduced in Infrahub 1.9.1
  • Tests

@github-actions github-actions Bot added the type/documentation Improvements or additions to documentation label Apr 28, 2026
@codecov

codecov Bot commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff             @@
##           develop     #976      +/-   ##
===========================================
- Coverage    82.02%   81.76%   -0.27%     
===========================================
  Files          135      135              
  Lines        11841    11659     -182     
  Branches      1762     1766       +4     
===========================================
- Hits          9713     9533     -180     
+ Misses        1576     1575       -1     
+ Partials       552      551       -1     
Flag Coverage Δ
integration-tests 41.67% <66.66%> (-0.95%) ⬇️
python-3.10 55.21% <100.00%> (-0.69%) ⬇️
python-3.11 55.23% <100.00%> (-0.68%) ⬇️
python-3.12 55.23% <100.00%> (-0.68%) ⬇️
python-3.13 55.23% <100.00%> (-0.68%) ⬇️
python-3.14 55.23% <100.00%> (-0.66%) ⬇️
python-filler-3.12 22.31% <0.00%> (+0.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/graphql.py 91.05% <100.00%> (+2.51%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 6, 2026

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: ccdf6dc
Status: ✅  Deploy successful!
Preview URL: https://1ad46071.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-graphql-query-report-ifc.infrahub-sdk-python.pages.dev

View logs


if online:
node = await client.get(
kind=CoreGraphQLQuery, # type: ignore[type-abstract]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary ignore until we can resolve the protocol issues within the SDK.

@ogenstad ogenstad marked this pull request as ready for review May 6, 2026 13:46
@ogenstad ogenstad requested a review from a team as a code owner May 6, 2026 13:46
@ogenstad ogenstad force-pushed the pog-graphql-query-report-ifc-2236 branch from a7f5a72 to 62f0ca0 Compare June 8, 2026 10:10
@ogenstad ogenstad force-pushed the pog-graphql-query-report-ifc-2236 branch from 62f0ca0 to a246e81 Compare June 8, 2026 10:12

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/docs/infrahubctl/infrahubctl-graphql.mdx">

<violation number="1" location="docs/docs/infrahubctl/infrahubctl-graphql.mdx:25">
P3: Command description references internal class `InfrahubGraphQLQueryReport` that is meaningless to end users. Replace with user-facing description such as 'Analyze a GraphQL query and report its characteristics, such as unique-target suitability for artifact definitions.'</violation>

<violation number="2" location="docs/docs/infrahubctl/infrahubctl-graphql.mdx:39">
P3: `--online` option description references internal type `CoreGraphQLQuery` that is not meaningful to users. Replace with user-facing wording such as '...from the Infrahub server (by query name) instead of...'</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


**Options**:

* `--online`: Fetch the query from the Infrahub server (CoreGraphQLQuery by name) instead of reading it from the local .infrahub.yml file.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: --online option description references internal type CoreGraphQLQuery that is not meaningful to users. Replace with user-facing wording such as '...from the Infrahub server (by query name) instead of...'

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/docs/infrahubctl/infrahubctl-graphql.mdx, line 39:

<comment>`--online` option description references internal type `CoreGraphQLQuery` that is not meaningful to users. Replace with user-facing wording such as '...from the Infrahub server (by query name) instead of...'</comment>

<file context>
@@ -16,9 +16,31 @@ $ infrahubctl graphql [OPTIONS] COMMAND [ARGS]...
+
+**Options**:
+
+* `--online`: Fetch the query from the Infrahub server (CoreGraphQLQuery by name) instead of reading it from the local .infrahub.yml file.
+* `--branch TEXT`: Branch on which to run the report.
+* `--config-file TEXT`: [env var: INFRAHUBCTL_CONFIG; default: infrahubctl.toml]
</file context>
Suggested change
* `--online`: Fetch the query from the Infrahub server (CoreGraphQLQuery by name) instead of reading it from the local .infrahub.yml file.
* `--online`: Fetch the query from the Infrahub server (by query name) instead of reading it from the local .infrahub.yml file.


## `infrahubctl graphql query-report`

Run a GraphQL query through InfrahubGraphQLQueryReport and report its analysis.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Command description references internal class InfrahubGraphQLQueryReport that is meaningless to end users. Replace with user-facing description such as 'Analyze a GraphQL query and report its characteristics, such as unique-target suitability for artifact definitions.'

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/docs/infrahubctl/infrahubctl-graphql.mdx, line 25:

<comment>Command description references internal class `InfrahubGraphQLQueryReport` that is meaningless to end users. Replace with user-facing description such as 'Analyze a GraphQL query and report its characteristics, such as unique-target suitability for artifact definitions.'</comment>

<file context>
@@ -16,9 +16,31 @@ $ infrahubctl graphql [OPTIONS] COMMAND [ARGS]...
 
+## `infrahubctl graphql query-report`
+
+Run a GraphQL query through InfrahubGraphQLQueryReport and report its analysis.
+
+**Usage**:
</file context>
Suggested change
Run a GraphQL query through InfrahubGraphQLQueryReport and report its analysis.
Analyze a GraphQL query and report its characteristics, such as unique-target suitability for artifact definitions.

@ogenstad ogenstad merged commit c26809b into develop Jun 8, 2026
21 checks passed
@ogenstad ogenstad deleted the pog-graphql-query-report-ifc-2236 branch June 8, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants