Skip to content

docs: add documentation for missing directives#2722

Merged
jensneuse merged 1 commit intomainfrom
docs/add-missing-directive-documentation
Apr 1, 2026
Merged

docs: add documentation for missing directives#2722
jensneuse merged 1 commit intomainfrom
docs/add-missing-directive-documentation

Conversation

@jensneuse
Copy link
Copy Markdown
Member

@jensneuse jensneuse commented Apr 1, 2026

Summary by CodeRabbit

  • Documentation
    • Added detailed documentation pages for four federation directives: @deprecated for marking deprecated schema elements, @specifiedBy for custom scalar specifications, @connect__fieldResolver for routing field resolution through gRPC, and @openfed__requireFetchReasons for fetch reason propagation. Updated the directives reference index.

…dResolver, and @openfed__requireFetchReasons directives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jensneuse jensneuse requested review from a team as code owners April 1, 2026 07:27
@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented Apr 1, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
wundergraphinc 🟢 Ready View Preview Apr 1, 2026, 7:28 AM

@jensneuse jensneuse requested a review from Noroth April 1, 2026 07:27
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2026

Walkthrough

Documentation pages for four new GraphQL federation directives (@deprecated, @specifiedBy, @connect__fieldResolver, @openfed__requireFetchReasons) were added to the docs website, with corresponding updates to the directives navigation index and federation-directives-index table.

Changes

Cohort / File(s) Summary
Navigation and Index Updates
docs-website/docs.json, docs-website/federation/federation-directives-index.mdx
Updated documentation navigation to include four new directive entries and expanded the directives index table with rows for @deprecated, @specifiedBy, @connect__fieldResolver, and @openfed__requireFetchReasons.
New Directive Documentation
docs-website/federation/directives/deprecated.mdx, docs-website/federation/directives/specifiedby.mdx, docs-website/federation/directives/connect__fieldresolver.mdx, docs-website/federation/directives/openfed__requirefetchreasons.mdx
Added comprehensive documentation for four federation directives, including GraphQL signatures, usage examples, argument descriptions, supported locations, and federation-specific composition behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Possibly related PRs

  • docs: add docs for requires in connect #2675: Updates federation directives documentation by adding new directive pages and updating the federation-directives-index.mdx table, mirroring the navigation and content expansion approach.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding documentation pages for four previously undocumented directives (@deprecated, @specifiedBy, @connect__fieldResolver, @openfed__requireFetchReasons) and updating navigation indices.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (5)
docs-website/federation/directives/specifiedby.mdx (2)

56-59: Document the composition behavior when URLs differ.

Line 57 states that "every subgraph that defines the same custom scalar should use the same @specifiedBy URL," but doesn't explain what happens if they differ. Based on relevant code snippets, the composition uses a last-one-wins strategy when URLs differ.

Consider documenting the actual behavior to set correct expectations.

📝 Suggested addition
 In a federated graph,
 every subgraph that defines the same custom scalar should use the same `@specifiedBy` URL.
+If subgraphs provide different URLs for the same scalar,
+composition preserves the last URL encountered without raising an error.
 Cosmo preserves the directive through composition so that introspection on the federated schema
 returns the `specifiedByURL` for each annotated scalar.

Based on relevant code snippets from composition/src/buildASTSchema/extendSchema.ts:375-388, which shows the last-one-wins merge strategy.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs-website/federation/directives/specifiedby.mdx` around lines 56 - 59,
Update the specifiedby.mdx text to document the composition behavior when
subgraphs provide different `@specifiedBy` URLs: explain that during composition
the implementation follows a "last-one-wins" merge strategy (as implemented in
extendSchema/extendSchema.ts), so the URL from the last-applied subgraph will be
preserved in the composed schema's specifiedByURL; mention this explicitly
alongside the existing guidance that subgraphs should use the same URL to avoid
surprises.

23-26: Consider splitting the long sentence.

Lines 23-26 contain a sentence with multiple comma-separated clauses. As per coding guidelines, prefer short, declarative sentences.

✏️ Suggested split
-It provides a machine-readable link between a custom scalar type and the document
-that describes its serialization,
-coercion,
-and validation rules.
+It links a custom scalar type to a document describing its format.
+The document specifies serialization, coercion, and validation rules.

As per coding guidelines, prefer short, declarative sentences when a sentence has more than one comma-separated clause.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs-website/federation/directives/specifiedby.mdx` around lines 23 - 26, The
long sentence "It provides a machine-readable link between a custom scalar type
and the document that describes its serialization, coercion, and validation
rules." should be split into shorter declarative sentences; edit the text so the
first sentence states that it provides a machine-readable link between a custom
scalar type and the document that describes its serialization, and follow with
one or two short sentences that state the document also describes coercion and
validation rules (e.g., split into "It provides a machine-readable link between
a custom scalar type and the document that describes its serialization. The
document also describes coercion and validation rules.").
docs-website/federation/directives/openfed__requirefetchreasons.mdx (2)

2-2: Title formatting inconsistency with directive name.

The title shows "@openfed requireFetchReasons" with a space, but the actual directive name is @openfed__requireFetchReasons with double underscores. Consider using the exact directive name for consistency with other directive documentation pages.

📝 Suggested correction
-title: "@openfed requireFetchReasons"
+title: "@openfed__requireFetchReasons"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs-website/federation/directives/openfed__requirefetchreasons.mdx` at line
2, Update the page title to match the actual directive name: replace the current
title string "@openfed requireFetchReasons" with the exact directive identifier
"@openfed__requireFetchReasons" so the header matches the directive symbol used
elsewhere (referencing the directive name `@openfed__requireFetchReasons`).

29-44: Consider tightening the compliance use-case explanation.

Lines 29-44 contain multiple long sentences with several comma-separated clauses explaining the compliance scenario. As per coding guidelines, prefer short, declarative sentences and avoid over-explanation.

✏️ Suggested refinement
-This is particularly useful for compliance-sensitive data.
 In a federated graph,
-any subgraph can use `@requires` to declare a dependency on a field from another subgraph.
-When that happens,
-the router fetches the field automatically — no explicit permission from the providing subgraph is needed.
+any subgraph can use `@requires` to declare a dependency on another subgraph's field.
+The router fetches the field automatically without explicit permission from the providing subgraph.
 For fields containing regulated or personally identifiable information,
-this means another team's subgraph could gain access to protected data
-without an explicit handshake.
+another team's subgraph could access protected data without an explicit handshake.

 With `@openfed__requireFetchReasons`,
-the providing subgraph can inspect every incoming request to see whether a field
-was requested by the end user or by another subgraph,
-and which subgraph it was.
-This allows the subgraph to maintain an allow list of subgraphs
-that are permitted to access specific fields,
-ensuring the data owner stays compliant with regulations.
+the providing subgraph can inspect each incoming request to determine whether a field was requested by the end user or by another subgraph.
+The subgraph can maintain an allow list of permitted subgraphs for specific fields.

As per coding guidelines, prefer short, declarative sentences and avoid over-explanation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs-website/federation/directives/openfed__requirefetchreasons.mdx` around
lines 29 - 44, The paragraph explaining the compliance use-case for
`@openfed__requireFetchReasons` and `@requires` uses long, comma-heavy sentences and
should be rewritten into short, declarative sentences: split compound sentences
into separate lines, remove redundant phrases (e.g., "this means"/"allow list"),
and state the core points plainly — (1) `@requires` lets a subgraph request fields
from another subgraph via the router; (2) that can expose regulated or PII
fields to other teams without explicit consent; (3)
`@openfed__requireFetchReasons` lets the providing subgraph see who requested a
field (end user vs. subgraph) and which subgraph requested it; (4) the subgraph
can then enforce an allow list to control access. Use these points to replace
the original paragraph with concise sentences.
docs-website/federation/directives/connect__fieldresolver.mdx (1)

29-34: Consider splitting the long example sentence.

Lines 29-34 form a single sentence with multiple comma-separated clauses. As per coding guidelines, prefer short, declarative sentences.

✏️ Suggested split
-For example,
-`id` and `price` on a `Product` type might come from a local database,
-while `shippingEstimate` requires a call to an external shipping service
-with higher latency.
-By annotating `shippingEstimate` with `@connect__fieldResolver`,
-the router only calls the shipping service when the client actually requests that field.
+For example:
+`id` and `price` on a `Product` type might come from a local database.
+`shippingEstimate` requires a call to an external shipping service with higher latency.
+Annotating `shippingEstimate` with `@connect__fieldResolver` ensures
+the router only calls the shipping service when the client requests that field.

As per coding guidelines, prefer short, declarative sentences when a sentence has more than one comma-separated clause.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs-website/federation/directives/connect__fieldresolver.mdx` around lines
29 - 34, The long example sentence explaining `@connect__fieldResolver` should be
split into shorter declarative sentences: locate the paragraph that begins "For
example, `id` and `price` on a `Product` type..." and break it into two or three
sentences such as stating where `id` and `price` come from (local DB) in one
sentence, explaining that `shippingEstimate` requires an external call in a
second sentence, and then a final sentence that explains annotating
`shippingEstimate` with `@connect__fieldResolver` causes the router to call the
shipping service only when that field is requested; keep wording concise and
preserve the original technical terms (`Product`, `id`, `price`,
`shippingEstimate`, `@connect__fieldResolver`, "router").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs-website/federation/directives/connect__fieldresolver.mdx`:
- Around line 29-34: The long example sentence explaining
`@connect__fieldResolver` should be split into shorter declarative sentences:
locate the paragraph that begins "For example, `id` and `price` on a `Product`
type..." and break it into two or three sentences such as stating where `id` and
`price` come from (local DB) in one sentence, explaining that `shippingEstimate`
requires an external call in a second sentence, and then a final sentence that
explains annotating `shippingEstimate` with `@connect__fieldResolver` causes the
router to call the shipping service only when that field is requested; keep
wording concise and preserve the original technical terms (`Product`, `id`,
`price`, `shippingEstimate`, `@connect__fieldResolver`, "router").

In `@docs-website/federation/directives/openfed__requirefetchreasons.mdx`:
- Line 2: Update the page title to match the actual directive name: replace the
current title string "@openfed requireFetchReasons" with the exact directive
identifier "@openfed__requireFetchReasons" so the header matches the directive
symbol used elsewhere (referencing the directive name
`@openfed__requireFetchReasons`).
- Around line 29-44: The paragraph explaining the compliance use-case for
`@openfed__requireFetchReasons` and `@requires` uses long, comma-heavy sentences and
should be rewritten into short, declarative sentences: split compound sentences
into separate lines, remove redundant phrases (e.g., "this means"/"allow list"),
and state the core points plainly — (1) `@requires` lets a subgraph request fields
from another subgraph via the router; (2) that can expose regulated or PII
fields to other teams without explicit consent; (3)
`@openfed__requireFetchReasons` lets the providing subgraph see who requested a
field (end user vs. subgraph) and which subgraph requested it; (4) the subgraph
can then enforce an allow list to control access. Use these points to replace
the original paragraph with concise sentences.

In `@docs-website/federation/directives/specifiedby.mdx`:
- Around line 56-59: Update the specifiedby.mdx text to document the composition
behavior when subgraphs provide different `@specifiedBy` URLs: explain that during
composition the implementation follows a "last-one-wins" merge strategy (as
implemented in extendSchema/extendSchema.ts), so the URL from the last-applied
subgraph will be preserved in the composed schema's specifiedByURL; mention this
explicitly alongside the existing guidance that subgraphs should use the same
URL to avoid surprises.
- Around line 23-26: The long sentence "It provides a machine-readable link
between a custom scalar type and the document that describes its serialization,
coercion, and validation rules." should be split into shorter declarative
sentences; edit the text so the first sentence states that it provides a
machine-readable link between a custom scalar type and the document that
describes its serialization, and follow with one or two short sentences that
state the document also describes coercion and validation rules (e.g., split
into "It provides a machine-readable link between a custom scalar type and the
document that describes its serialization. The document also describes coercion
and validation rules.").

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34360c94-aa64-4ddf-89e5-b74ce7226bf5

📥 Commits

Reviewing files that changed from the base of the PR and between 1a182a7 and 90cfe7f.

📒 Files selected for processing (6)
  • docs-website/docs.json
  • docs-website/federation/directives/connect__fieldresolver.mdx
  • docs-website/federation/directives/deprecated.mdx
  • docs-website/federation/directives/openfed__requirefetchreasons.mdx
  • docs-website/federation/directives/specifiedby.mdx
  • docs-website/federation/federation-directives-index.mdx

@jensneuse jensneuse merged commit 43e52a8 into main Apr 1, 2026
13 checks passed
@jensneuse jensneuse deleted the docs/add-missing-directive-documentation branch April 1, 2026 12:29
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.

1 participant