--------------------
The federation decorator now allows for a list of additional arbitrary schema
directives extending the key/shareable directives used for federation.
Example Python:
python
import strawberry
from strawberry.schema.config import StrawberryConfig
from strawberry.schema_directive import Location
strawberry.schema_directive(locations=[Location.OBJECT])
class CacheControl:
max_age: int
strawberry.federation.type(
keys=["id"], shareable=True, extend=True, directives=[CacheControl(max_age=42)]
)
class FederatedType:
id: strawberry.ID
schema = strawberry.Schema(query=Query, config=StrawberryConfig(auto_camel_case=False))
Resulting GQL Schema:
graphql
directive CacheControl(max_age: Int!) on OBJECT
directive key(fields: _FieldSet!, resolvable: Boolean) on OBJECT | INTERFACE
directive shareable on FIELD_DEFINITION | OBJECT
extend type FederatedType
key(fields: "id")
shareable
CacheControl(max_age: 42) {
id: ID!
}
type Query {
federatedType: FederatedType!
}
Contributed by [Jeffrey DeFond](https://github.com/defond0) via [PR #1945](https://github.com/strawberry-graphql/strawberry/pull/1945/)