Skip to content

Conversation

@ysmolski
Copy link
Contributor

@ysmolski ysmolski commented Oct 10, 2025

When an interface field is marked,
and a user requests that field in an operation,
then fetch reasons for this field will be extended
with fetch reasons for all the implementing types.

In general, a marked interface field leads to all
implementation's fields being used for propagation.

I have removed special config needed for testing fetch reasons.
Instead I added those directives to the demo package.

Bumped the shoenig/go-m1cpu package to get rid of warnings from xcode 26.

Summary by CodeRabbit

  • New Features

    • Added a repeatable GraphQL directive (openfed__requireFetchReasons) usable on fields, interfaces, and objects.
    • Router now includes fetch_reasons data in response extensions when the directive is applied (e.g., on employee and Query fields).
  • Tests

    • Expanded integration tests to verify rendered subgraph queries and the presence of fetch_reasons in extensions.
  • Chores

    • Upgraded dependencies, including graphql-go-tools to v2.0.0-rc.230 and go-m1cpu to v0.1.7.

@ysmolski ysmolski requested review from JivusAyrus and removed request for a team October 10, 2025 10:27
@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2025

Walkthrough

Dependency bumps in go.mod files, a new repeatable GraphQL directive added and applied in the employees subgraph schema, router tests updated to use a different config template and to assert fetch_reasons in extensions, and a testenv exported template variable removed.

Changes

Cohort / File(s) Summary of changes
Go module updates
demo/go.mod, router/go.mod, router-tests/go.mod
Bumped dependencies: github.com/shoenig/go-m1cpu v0.1.6 → v0.1.7; github.com/wundergraph/graphql-go-tools/v2 rc.229 → rc.230 (router and router-tests).
Subgraph schema directive
demo/pkg/subgraphs/employees/subgraph/schema.graphqls
Added repeatable directive @openfed__requireFetchReasons (FIELD_DEFINITION, INTERFACE, OBJECT). Applied to employee(id: Int!): Employee field and interface Identifiable.
Router tests updates
router-tests/integration_test.go, router-tests/testenv/testenv.go
Tests: switched RouterConfigJSONTemplate to testenv.ConfigJSONTemplate; added assertions for rendered query and extensions.fetch_reasons for Employee and Query. Testenv: removed exported ConfigWithRequireFetchReasonsJSONTemplate and its embed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title accurately captures the core change of enabling the requireFetchReasons directive on interface fields and is both concise and specific to the implemented modifications.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a31f95 and e74e094.

⛔ Files ignored due to path filters (3)
  • demo/go.sum is excluded by !**/*.sum
  • router-tests/go.sum is excluded by !**/*.sum
  • router/go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • demo/go.mod (1 hunks)
  • demo/pkg/subgraphs/employees/subgraph/schema.graphqls (2 hunks)
  • router-tests/go.mod (2 hunks)
  • router-tests/integration_test.go (2 hunks)
  • router-tests/testenv/testenv.go (0 hunks)
  • router/go.mod (2 hunks)
💤 Files with no reviewable changes (1)
  • router-tests/testenv/testenv.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-20T22:13:25.222Z
Learnt from: StarpTech
PR: wundergraph/cosmo#2157
File: router-tests/go.mod:16-16
Timestamp: 2025-08-20T22:13:25.222Z
Learning: github.com/mark3labs/mcp-go v0.38.0 has regressions and should not be used in the wundergraph/cosmo project. v0.36.0 is the stable version that should be used across router-tests and other modules.

Applied to files:

  • router-tests/go.mod
🧬 Code graph analysis (1)
router-tests/integration_test.go (1)
router-tests/testenv/testenv.go (1)
  • ConfigJSONTemplate (81-81)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: build_push_image
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./events)
  • GitHub Check: image_scan (nonroot)
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: build_test
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (8)
demo/go.mod (1)

130-130: LGTM!

The minor version bump to v0.1.7 eliminates warnings from Xcode 26 as stated in the PR description and is coordinated with similar updates across other modules.

router/go.mod (1)

34-34: LGTM!

Both dependency bumps are appropriate:

  • graphql-go-tools/v2rc.230 provides support for the requireFetchReasons directive feature
  • shoenig/go-m1cpuv0.1.7 eliminates Xcode 26 warnings

The updates are coordinated with similar changes across other modules in this PR.

Also applies to: 151-151

router-tests/go.mod (1)

30-30: LGTM!

The dependency updates are properly coordinated with other modules:

  • graphql-go-tools/v2rc.230 enables testing of the requireFetchReasons directive
  • shoenig/go-m1cpuv0.1.7 eliminates Xcode 26 warnings

Note: mark3labs/mcp-go correctly remains at v0.36.0 (the stable version).

Based on learnings.

Also applies to: 137-137

demo/pkg/subgraphs/employees/subgraph/schema.graphqls (3)

27-28: LGTM!

The directive declaration is well-defined:

  • Marked as repeatable for flexibility
  • Targets appropriate schema locations: FIELD_DEFINITION, INTERFACE, and OBJECT
  • Naming convention with openfed__ prefix follows OpenFederation standards

30-30: LGTM!

Applying @openfed__requireFetchReasons to the employee field ensures fetch reasons are tracked for this Query field, as verified by the test assertions in integration_test.go (line 856).


85-87: LGTM!

Applying @openfed__requireFetchReasons to the Identifiable interface correctly enables fetch reason tracking for the id field on all implementing types (e.g., Employee). This is verified by the test assertion in integration_test.go that checks for {"typename":"Employee","field":"id","by_user":true} in the fetch_reasons extension.

router-tests/integration_test.go (2)

841-841: LGTM!

Excellent refactoring. The test now uses the standard testenv.ConfigJSONTemplate instead of a special template, as the requireFetchReasons functionality is now controlled by schema directives rather than configuration. This makes the feature more explicit and maintainable.


853-856: LGTM!

The assertions correctly verify that the @openfed__requireFetchReasons directive works on both:

  1. Query fields (Query.employee from line 30 of schema.graphqls)
  2. Interface fields (Employee.id inherited from Identifiable interface at line 85 of schema.graphqls)

The expected fetch_reasons extension data matches the directive applications in the schema.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Oct 10, 2025

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-5c565c39c8ef7ec97f17224ca7271eaa67944c3b

@ysmolski ysmolski changed the title fix: propagate fetch reasons on interfaces fix: support requireFetchReasons on interface fields Oct 10, 2025
…yury/eng-8266-support-requirefetchreasons-on-interface-fields
Base automatically changed from david/eng-8262-propagate-interface-fetch-reasons to main October 10, 2025 12:58
@ysmolski ysmolski requested a review from Aenimus as a code owner October 10, 2025 12:58
Copy link
Member

@Aenimus Aenimus left a comment

Choose a reason for hiding this comment

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

LGTM!

@ysmolski ysmolski merged commit 97bd5cd into main Oct 10, 2025
29 checks passed
@ysmolski ysmolski deleted the yury/eng-8266-support-requirefetchreasons-on-interface-fields branch October 10, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants