Repository navigation
feat: add Apollo Connectors spec definitions - #24
Merged
Merged
Conversation
- Honour `@link(as: ...)` on the federation link: elements that aren't imported are namespaced under the alias instead of `federation__`. - Follow the link spec's own `@link(url: ".../link/v1.0", import: [...])` for `Import` / `Purpose` instead of always using `link__Import` / `link__Purpose`, and reject imports it doesn't define. - Reject a trailing slash after the version in `@link` URLs, as composition does. - Share `@link` parsing (`linksTo`, `parseVersion`, `specLink`) so other specifications can reuse it; `UnsupportedLinkImportError.unknownName` now takes the specification description instead of a version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `@link` url is only a link to a known specification when its version directly follows the specification identity. As in composition, the last path segment is the version and the one before it the specification name, so `https://specs.apollo.dev/federation/extra/v1.0` links a custom specification named `extra`. It was read as a federation link, which rejected schemas that also linked federation (MultipleFederationLinksError) even though they compose. A trailing slash after the version is still matched, and rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A subgraph that `@link`s `https://specs.apollo.dev/connect/v0.1` through `v0.4` gets the `@connect` and `@source` directives and their supporting types, following the link's `import` list and `as` namespace. - Definitions match what composition v2.15+ expects (e.g. `URLTemplate`). - `@connect` takes the namespace as its name when it isn't imported (`@connect`, or `@<as>`), as composition names it. - A connectors subgraph's `_service { sdl }` leaves out the `_service` / `_entities` machinery, which composition rejects there. - Connector usage itself is still validated by composition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dariuszkuc
force-pushed
the
dk/connect-spec
branch
from
November 10, 2026 01:12
f96448c to
4ac75b2
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tninesling
approved these changes
Nov 16, 2026
# Conflicts: # src/__tests__/buildSubgraphSchema.test.ts # src/buildSubgraphSchema.ts # src/link.ts # src/specs.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
dariuszkuc
pushed a commit
that referenced
this pull request
Nov 17, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @apollo/subgraph@2.17.0 ### Minor Changes - [#24](#24) [`4d9e75c`](4d9e75c) Thanks [@dariuszkuc](https://github.com/dariuszkuc)! - Add Apollo Connectors spec definitions. A subgraph that `@link`s `https://specs.apollo.dev/connect/v0.1` through `v0.4` now gets the `@connect` and `@source` directives and their supporting types, following the link's `import` list and `as` namespace, with the definitions composition (v2.15+) expects. Connector usage itself is still validated by composition. A connectors subgraph's `_service { sdl }` leaves out the `_service` / `_entities` fields and the `_Service`, `_Any` and `_Entity` types, which composition rejects in a connectors subgraph. The schema still serves them. ### Patch Changes - [#23](#23) [`1f7d99a`](1f7d99a) Thanks [@dariuszkuc](https://github.com/dariuszkuc)! - Align `@link` handling with composition: - `@link(as: ...)` is now honoured for the federation link, so elements that aren't imported are namespaced under the alias instead of `federation__`. - `@link(url: "https://specs.apollo.dev/link/v1.0", import: [...])` now names `Import` and `Purpose` after its imports instead of always using `link__Import` / `link__Purpose`. - A `@link` URL with a trailing slash after the version (`.../federation/v2.9/`) is now rejected, matching composition. - A `@link` URL with extra path segments under a known specification (`https://specs.apollo.dev/federation/extra/v1.0`) now links a custom specification (`extra`), as in composition, instead of being read as a federation link. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the Apollo Connectors (
@connect/@source) spec definitions, so subgraph schemas that@linkhttps://specs.apollo.dev/connect/v0.1throughv0.4can be built, printed and inspected. Connectors are executed by the router; validating how they're used stays with composition.Changes
@connect,@source,JSONSelection,URLTemplate,ConnectorErrors,HTTPHeaderMapping,ConnectBatch,SourceHTTP,ConnectHTTP), named by the link'simportlist andasnamespace. Definitions the schema already declares are left alone. They match what composition v2.15+ expects; for example, the scalar isURLTemplate, not theURLPathTemplateused by the older JavaScript composition, which 2.15 rejects.@connecttakes the namespace as its name when it isn't imported (@connect, or@restwithas: "rest"), the same way composition names a directive that shares its spec's name.@sourceand the types are still prefixed (connect__source)._service { sdl }leaves out the_service/_entitiesfields and the_Service,_Anyand_Entitytypes. Composition requires every field in a connectors subgraph to be resolved by a connector (and, before connect v0.4, rejects unions such as_Entity), so publishing them breaks composition. The published 2.14.x package has the same problem. The schema still serves them. Schemas that don't link connect are unaffected.MultipleConnectLinksErrorandUnsupportedConnectVersionError;CONNECT_SPEC_IDENTITYandLATEST_CONNECT_VERSIONare exported.Connect v0.5 (which needs federation v3.0) will come in a follow-up.
Verification
_service { sdl }(with the machinery left out) composes with composition 2.15.0 and 2.15.4 for:@connectwith no importas: "rest"/@restNo connector resolves field Query._service, or the union error on v0.1–v0.3).fill-schema-gaps), except for@external(reason:), which is left out on purpose.🤖 Generated with Claude Code