def METHOD_NAME(
    _root, info: ResolveInfo, /, *, sort_by=None, filter=None, search=None, **kwargs
):
    sorting_by_balance = sort_by and "current_balance_amount" in sort_by.get(
        "field", []
    )
    filtering_by_currency = filter and "currency" in filter
    if sorting_by_balance and not filtering_by_currency:
        raise GraphQLError("Sorting by balance requires filtering by currency.")
    qs = METHOD_NAME()
    if search:
        qs = search_gift_cards(qs, search)
    qs = filter_connection_queryset(
        qs, {"sort_by": sort_by, "filter": filter, **kwargs}
    )
    return create_connection_slice(
        qs,
        info,
        {"sort_by": sort_by, "filter": filter, **kwargs},
        GiftCardCountableConnection,
    )