GitHub

API reference for group.

Groups of GraphQL operations (Effect's GraphQLGroup).

A group is a class whose attributes are operations; client.make(Group) gives an instance whose attributes are their methods. The type argument names the middleware every operation of the group runs, outermost first::

class Issues(GraphQLGroup[Auth | Logging]):
    repo_issues = RepoIssues
    issue_updated = IssueUpdated

Read on the class, an operation carries the group's middleware, so another group takes it with it (Effect's GraphQLGroup.merge)::

class Everything(GraphQLGroup):
    repo_issues = Issues.repo_issues
    viewer = Viewer

Classes

Functions

group_middlewares

group_middlewares(owner) -> tuple[AnyMiddleware, ...]

The middleware classes of class G(GraphQLGroup[M]) (or of a subclass of it), outermost first; none for any other class.

ParameterTypeDescription
ownertype

Returns tuple[AnyMiddleware, ...]

def group_middlewares(owner: type) -> tuple[AnyMiddleware, ...]:
    """The middleware classes of ``class G(GraphQLGroup[M])`` (or of a
    subclass of it), outermost first; none for any other class."""
    arguments = _group_arguments(owner)
    return _middleware_classes(arguments[0]) if arguments else ()

operation_middlewares

operation_middlewares(owner) -> tuple[AnyMiddleware, ...]

The middleware classes declared as GraphQLGroup[M, OM]'s OM.

ParameterTypeDescription
ownertype

Returns tuple[AnyMiddleware, ...]

def operation_middlewares(owner: type) -> tuple[AnyMiddleware, ...]:
    """The middleware classes declared as ``GraphQLGroup[M, OM]``'s ``OM``."""
    arguments = _group_arguments(owner)
    return _middleware_classes(arguments[1]) if len(arguments) > 1 else ()

operations_of

operations_of(group) -> list[AnyOperation]

The operations of group's attributes, each once; an attribute a subclass overrides holds the subclass's operation. Raises ValueError for two operations with one name.

ParameterTypeDescription
grouptype[GraphQLGroup[Any, Any]]

Returns list[AnyOperation]

def operations_of(group: type[GraphQLGroup[Any, Any]]) -> list[AnyOperation]:
    """The operations of ``group``'s attributes, each once; an attribute a
    subclass overrides holds the subclass's operation. Raises
    ``ValueError`` for two operations with one name."""
    attributes: dict[str, object] = {}
    for cls in reversed(group.__mro__):
        attributes.update(vars(cls))
    by_name: dict[str, AnyOperation] = {}
    for value in attributes.values():
        if not isinstance(value, (Operation, Subscription)):
            continue
        operation: AnyOperation = cast("OperationInfo", value)
        existing = by_name.get(operation.name)
        if existing is not None and existing is not operation:
            raise ValueError(f'GraphQLGroup: duplicate operation name "{operation.name}"')
        by_name[operation.name] = operation
    return list(by_name.values())

method_of

method_of(instance, operation) -> object

The method of operation on a client.

ParameterTypeDescription
instanceobject
operationAnyOperation

Returns object

def method_of(instance: object, operation: AnyOperation) -> object:
    """The method of ``operation`` on a client."""
    return cast("GraphQLGroup[Any, Any]", instance)._methods[operation]  # pyright: ignore[reportPrivateUsage]