Ariadne is a Python library for implementing GraphQL servers using a schema-first approach.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Support for Apollo Federation allowing microservice architecture with federated GraphQL schemas.
class FederatedObjectType(ObjectType):
"""Object type with Apollo Federation support."""
def __init__(self, name: str): ...
def reference_resolver(self, resolver_func: Callable):
"""Set entity reference resolver."""
class FederatedInterfaceType(InterfaceType):
"""Interface type with Apollo Federation support."""
def __init__(self, name: str): ...
def reference_resolver(self, resolver_func: Callable):
"""Set entity reference resolver."""def make_federated_schema(
type_defs: Union[str, list[str]],
*bindables,
**kwargs
) -> GraphQLSchema:
"""Create Apollo Federation-compatible schema."""from ariadne.contrib.federation import FederatedObjectType, make_federated_schema
type_defs = """
extend type User @key(fields: "id") {
id: ID! @external
posts: [Post!]!
}
"""
user_type = FederatedObjectType("User")
@user_type.reference_resolver
def resolve_user_reference(representation):
return get_user_by_id(representation["id"])
schema = make_federated_schema(type_defs, user_type)Install with Tessl CLI
npx tessl i tessl/pypi-ariadne