Repository navigation
Implement all missing Apollo Federation directives - #2774
eriksulymosi wants to merge 12 commits into
Conversation
|
Hi @spawnia, Just wanted to gently ping this PR to see if anyone has a moment to check it out. It introduces support for a few essential Apollo Router directives directly into Lighthouse. This will make it much easier for developers using Lighthouse in a federated architecture or alongside Apollo Router to leverage these directives out of the box. The implementation is non-breaking, well-scoped, and all tests are passing. Let me know if you have any feedback or if you'd like me to tweak anything! Thanks for your time and for this great package. 🙏 |
|
Hi! Just wanted to gently bump this PR since it's been quiet for a while. Whenever you have some bandwidth, I'd greatly appreciate it if you could take a look. Let me know if any adjustments are needed! Thanks! |
There was a problem hiding this comment.
🟡 Changes recommended
Valid interface, scalar, and enum authorization directives are omitted from generated federation SDL.
1 open finding
What changed in this PR
Adds Apollo Federation authorization directives and preserves them in generated subgraph SDL.
Changes:
- Adds
@authenticated,@requiresScopes, and@policy. - Registers directives with federation schema printing.
- Adds documentation and integration coverage.
| File | Description |
|---|---|
src/Federation/Directives/AuthenticatedDirective.php |
Defines @authenticated. |
src/Federation/Directives/RequiresScopesDirective.php |
Defines scope-based authorization. |
src/Federation/Directives/PolicyDirective.php |
Defines policy-based authorization. |
src/Federation/FederationPrinter.php |
Preserves authorization directives in SDL. |
tests/Integration/Federation/FederationSchemaTest.php |
Tests object and field directives. |
docs/6/federation/getting-started.md |
Documents directive imports. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…phQL types and directives
|
I originally opened this PR to implement the authorization-related Apollo Federation directives. However, I've since expanded its scope and implemented all the other missing Federation directives as well. With these changes, I've completed the implementation of all previously missing Apollo Federation directives in Lighthouse. |
| foreach ($definitions as $value) { | ||
| if ($value->astNode === null) { | ||
| foreach ($type->astNode->values ?? [] as $valueNode) { | ||
| if ($valueNode->name->value === $value->name) { | ||
| $value = clone $value; | ||
| $value->astNode = $valueNode; | ||
| break; | ||
| } | ||
| } | ||
| } |
Add @fromcontext directive for context field selection. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>


Resolves #
Changes
This PR introduces support for Apollo-style declarative authorization directives within Lighthouse. This allows schemas to better align with Apollo Router / Federation standards for authorization handled at the gateway or subgraph level.
Key additions:
@authenticated,@requiresScopes,@policy) to control field and type accessibility.Breaking changes
None. This is a purely additive feature and does not affect existing
@can,@author@guarddirectives implemented natively by Lighthouse.