use serde::{Deserialize, Serialize}; use utoipa::ToSchema; /// Arguments used for cursor-based pagination. #[derive(Deserialize, Debug, ToSchema)] #[serde(rename_all = "camelCase")] pub struct PaginationArgs { /// Returns the first `n` items from the list. pub first: Option, /// A cursor pointing to the position after which items should be returned. pub after: Option, /// Returns the last `n` items from the list. pub last: Option, /// A cursor pointing to the position before which items should be returned. pub before: Option, } /// Metadata describing the current page of results. #[derive(Serialize, Debug, ToSchema)] #[serde(rename_all = "camelCase")] pub struct PageInfo { /// Indicates whether there are more items when paginating forward. pub has_next_page: bool, /// Indicates whether there are more items when paginating backward. pub has_previous_page: bool, /// The cursor corresponding to the first item in the current page. pub start_cursor: Option, /// The cursor corresponding to the last item in the current page. pub end_cursor: Option, } /// A paginated connection containing edges and pagination metadata. #[derive(Serialize, Debug, ToSchema)] #[serde(rename_all = "camelCase")] pub struct Connection { /// A list of edges, each containing a node and its cursor. pub edges: Vec>, /// Information about pagination for this connection. pub page_info: PageInfo, } /// An edge in a connection, representing a node and its cursor. #[derive(Serialize, Debug, ToSchema)] #[serde(rename_all = "camelCase")] pub struct Edge { /// The item/node contained in this edge. pub node: T, /// A cursor for this node, used in pagination. pub cursor: String, }