CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-ariadne

Ariadne is a Python library for implementing GraphQL servers using a schema-first approach.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

relay.mddocs/

Relay Support

Implementation of Relay specifications including connections, global object identification, and pagination.

Capabilities

Relay Types

class RelayObjectType(ObjectType):
    """Object type with Relay connection support."""

class RelayQueryType(QueryType):
    """Query type with Relay node interface support."""

class RelayNodeInterfaceType(InterfaceType):
    """Relay Node interface implementation."""

Relay Connections

class RelayConnection:
    """Implementation of Relay connection specification."""
    
    def __init__(
        self,
        edges: list,
        page_info: dict,
        total_count: Optional[int] = None
    ): ...

class ConnectionArguments:
    """Arguments for Relay connections."""
    first: Optional[int]
    after: Optional[str]
    last: Optional[int]
    before: Optional[str]

Global ID Utilities

def encode_global_id(type_name: str, node_id: str) -> str:
    """Encode global ID for Relay."""

def decode_global_id(global_id: str) -> tuple[str, str]:
    """Decode global ID from Relay, returns (type_name, node_id)."""

Types

ConnectionResolver = Callable
GlobalIDTuple = tuple[str, str]

Usage Examples

from ariadne.contrib.relay import (
    RelayQueryType, RelayConnection, encode_global_id, decode_global_id
)

query = RelayQueryType()

@query.field("node")
def resolve_node(_, info, id):
    type_name, node_id = decode_global_id(id)
    if type_name == "User":
        return get_user(node_id)
    return None

# Connection resolver
@query.field("users")
def resolve_users_connection(_, info, first=None, after=None):
    users = get_users(first=first, after=after)
    return RelayConnection(
        edges=[{"node": user, "cursor": encode_cursor(user.id)} for user in users],
        page_info={"hasNextPage": True, "hasPreviousPage": False}
    )

Install with Tessl CLI

npx tessl i tessl/pypi-ariadne

docs

asgi.md

core-schema.md

error-handling.md

execution.md

explorer.md

federation.md

file-uploads.md

index.md

relay.md

resolvers.md

type-bindables.md

validation.md

tile.json