Registry / web-framework / graphene-federation

graphene-federation

JSON →
library3.3.0pypypi✓ verified 83d ago

Federation implementation for Graphene. Adds support for Apollo Federation (v1 and v2) to GraphQL schemas built with graphene. Current version 3.3.0 supports Federation v2.11 directives. Active development.

pip install graphene-federation
INSTALL
IMPORT
SIG · GRAPHENE-FEDERATIO
G
graphene-federation
web-frameworkpythonv3.3.0
Install
2.2s avg
Import
517ms
Disk
22MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.538s · 23.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.2s · import 0.496s · 24MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

build_schema
from graphene_federation import build_schema
extends
from graphene_federation import extends
key
from graphene_federation import key
external
from graphene_federation import external
provides
from graphene_federation import provides
requires
from graphene_federation import requires
authenticated
from graphene_federation import authenticated
requiresScopes
from graphene_federation import requiresScopes
policy
from graphene_federation import policy
shareable
from graphene_federation import shareable
inaccessible
from graphene_federation import inaccessible
tag
from graphene_federation import tag
override
from graphene_federation import override
composeDirective
from graphene_federation import composeDirective
link__Purpose
from graphene_federation import link__Purpose
Used in Federation v2 directive composition.
external
from graphene_federation import external
cost
from graphene_federation import cost
New in v3.3.0
listSize
from graphene_federation import listSize
New in v3.3.0
context
from graphene_federation import context
New in v3.3.0
fromContext
from graphene_federation import fromContext
New in v3.3.0
enable_federation_2
from graphene_federation import enable_federation_2
Deprecated in v3.2.0. Use federation_version parameter instead.

Basic graphene federation schema using @extends and @key.

import graphene from graphene_federation import build_schema, key, extends @key('id') @extends class Product(graphene.ObjectType): id = graphene.ID(required=True) name = graphene.String() class Query(graphene.ObjectType): product = graphene.Field(Product, id=graphene.ID(required=True)) def resolve_product(self, info, id): return Product(id=id) schema = build_schema(query=Query) print(schema)
Debug
Known issues
breakingIn v3.2.0, the @extend directive was removed. Replace with @extends + @key for V1, or just @key for V2.
fix
Replace @extend decorator with @extends (and @key if not already present).
affects: >=3.2.0
deprecatedenable_federation_2() function is deprecated. Use federation_version parameter in build_schema() instead.
fix
Remove enable_federation_2() call and pass federation_version=2 to build_schema().
affects: >=3.2.0
gotchaFederation v2 requires all types to have @key directive. Missing @key on an entity type leads to runtime errors in Apollo Gateway.
fix
Add @key to all entity types using '@key('id')' or other field combinations.
affects: >=3.1.0
gotchaWhen using Federation v2 with @shareable, ensure that fields marked @shareable are resolved consistently across subgraphs or expect composition errors.
fix
Define resolvers returning identical values for @shareable fields or avoid marking them as shareable if they differ.
affects: >=3.1.0
Errors
Common errors & fixes
ImportError: cannot import name 'enable_federation_2' from 'graphene_federation'
enable_federation_2 was removed in v3.2.0.
fix
Use federation_version parameter: schema = build_schema(query=Query, federation_version=2)
NameError: name 'extend' is not defined
The @extend decorator was removed in v3.2.0.
fix
Replace @extend with @extends and ensure @key is present.
TypeError: build_schema() got an unexpected keyword argument 'federation_2'
Old code still using enable_federation_2 pattern but upgrade to v3.2.0 removed it.
fix
Use build_schema(query=Query, federation_version=2) instead.
AttributeError: module 'graphene_federation' has no attribute 'cost'
Using older version (<3.3.0) of graphene-federation that does not include 'cost' directive.
fix
Upgrade to v3.3.0: pip install --upgrade graphene-federation
Upgrade
Version history
3.3.0latest on PyPI · released Oct 9, 2025
Audit
Dependencies
graphenerequiredPeer dependency; federation is an extension of graphene.
graphql-corerequiredRequired for GraphQL type system.
Agent activity
13 hits · last 30 days
node
12
Resources
graphene-federation — pip install graphene-federation · libregistry