account.rs

Overview

This file defines GraphQL query types and structures related to account data retrieval and pagination of account-related events for an application using a GraphQL API. It provides mechanisms to query account information as well as to paginate through account events such as outgoing external messages. The file leverages asynchronous database access, cursor-based pagination, and GraphQL connection patterns to enable efficient data fetching.

Key Components

Structs and Their Purpose

SingleAccount

A simple GraphQL object representing an individual account with the following fields:

Implementation Details

AccountQuery

Represents a GraphQL query context for a specific account address.

AccountEventEdge and AccountEventsConnection

Custom types implementing GraphQL connection traits for paginating account events:

These types are used in the cursor-based pagination of account events.


Detailed Function and Method Descriptions

impl From<db::Account> for SingleAccount


impl AccountQuery

This implementation block exposes two main asynchronous GraphQL query methods:

async fn info(&self, ctx: &Context<'_>) -> Option<SingleAccount>

async fn events(...) -> Option<Connection<...>>


Important Implementation Details and Algorithms


Interaction with Other System Components


Mermaid Diagram: Structure of account.rs

classDiagram
class SingleAccount {
+id: String
+boc: Option<String>
+dapp_id: Option<String>
}
class AccountQuery {
+address: String
+preloaded: Option<db::Account>
+info()
+events()
}
class AccountEventEdge {
<<EdgeNameType>>
}
class AccountEventsConnection {
<<ConnectionNameType>>
}
SingleAccount <|-- db::Account : From
AccountQuery ..> SqlitePool : uses
AccountQuery ..> Arc~ClientContext~ : uses
AccountQuery ..> AccountEventEdge : uses for pagination
AccountQuery ..> AccountEventsConnection : uses for pagination
AccountQuery ..> Event : events output node

This class diagram shows the primary data structures and their relationships in the file. It highlights how AccountQuery serves as the main query type, depending on database and client contexts, and how it leverages custom connection and edge types for paginating events.