docs/breaking-changes/0.285.0.md
This release removes support for Apollo Federation v1 and updates the federation API to always use Federation v2.
The enable_federation_2 parameter has been removed and replaced with
federation_version. Federation v2 is now always enabled, with version 2.11 as
the default.
# Before (0.284.x and earlier)
schema = strawberry.federation.Schema(
query=Query, enable_federation_2=True # Opt-in to Federation 2
)
# After (0.285.0+)
schema = strawberry.federation.Schema(
query=Query, federation_version="2.11" # Defaults to "2.11", always Federation 2
)
If you were already using enable_federation_2=True, you can remove that
parameter:
# Before
schema = strawberry.federation.Schema(query=Query, enable_federation_2=True)
# After
schema = strawberry.federation.Schema(query=Query)
Your schemas will continue to work without changes and will now default to Federation v2.11.
If you were using Federation v1 (without enable_federation_2), you must
migrate to Federation v2. Apollo Federation v1 is no longer supported by
Strawberry.
Federation v2 provides better schema composition and additional features. Most v1 schemas can be migrated with minimal changes:
# Before (Federation v1)
schema = strawberry.federation.Schema(query=Query)
# After (Federation v2)
schema = strawberry.federation.Schema(query=Query) # Now uses v2.11
Key differences in Federation v2:
extend keyword needed: Types no longer need to be marked as
extensions@external required: The @key directive alone is sufficient in most
cases@shareable directive: Use this to indicate fields that can be resolved
by multiple subgraphs@link directive: Automatically added to declare federation spec versionSee the Apollo Federation v2 migration guide for more details.
You can now specify which Federation v2 version to use:
schema = strawberry.federation.Schema(
query=Query, federation_version="2.5" # Use a specific version
)
Supported versions: 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11
This is useful if you need to ensure compatibility with a specific Apollo Router or Gateway version, or if you want to avoid using newer directives.
Strawberry validates that directives are compatible with your chosen federation version:
from strawberry.federation.schema_directives import Cost
@strawberry.federation.type
class Product:
name: str = strawberry.federation.field(
directives=[Cost(weight=10)] # Requires v2.9+
)
# This will raise an error because @cost requires v2.9+
schema = strawberry.federation.Schema(
query=Query, federation_version="2.5" # Too old for @cost
)
If you're using enable_federation_2=False or not setting it at all, you're
using Federation v1 and need to migrate.
# Remove this parameter
schema = strawberry.federation.Schema(
query=Query, enable_federation_2=True # Remove this line
)
If you were using Federation v1 patterns like extend=True and explicit
@external fields, you can simplify:
# Before (Federation v1)
@strawberry.federation.type(keys=["id"], extend=True)
class Product:
id: strawberry.ID = strawberry.federation.field(external=True)
reviews: list[Review]
# After (Federation v2)
@strawberry.federation.type(keys=["id"])
class Product:
id: strawberry.ID
reviews: list[Review]
Run your schema composition and tests to ensure everything works correctly with Federation v2.