pub struct QueryBuilder { /* private fields */ }Expand description
Builder for GraphQL collection queries.
Produces Relay-style connection queries against pg_graphql.
§Example
ⓘ
let connection = client.collection("blogCollection")
.select(&["id", "title", "createdAt"])
.filter(GqlFilter::eq("status", "published"))
.order_by("createdAt", OrderByDirection::DescNullsLast)
.first(10)
.total_count()
.execute::<BlogRow>().await?;Implementations§
Source§impl QueryBuilder
impl QueryBuilder
Sourcepub fn order_by(self, column: &str, direction: OrderByDirection) -> Self
pub fn order_by(self, column: &str, direction: OrderByDirection) -> Self
Add an order-by clause.
Sourcepub fn total_count(self) -> Self
pub fn total_count(self) -> Self
Include the totalCount field in the response.
Sourcepub fn build(&self) -> (String, Value)
pub fn build(&self) -> (String, Value)
Build the query string and variables without executing.
Returns (query_string, variables) for inspection or debugging.
Sourcepub async fn execute<T: DeserializeOwned>(
self,
) -> Result<Connection<T>, GraphqlError>
pub async fn execute<T: DeserializeOwned>( self, ) -> Result<Connection<T>, GraphqlError>
Execute the query and return a typed Connection<T>.
The response data field is expected to have the shape:
{ "collectionName": { "edges": [...], "pageInfo": {...}, "totalCount": ... } }
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryBuilder
impl !RefUnwindSafe for QueryBuilder
impl Send for QueryBuilder
impl Sync for QueryBuilder
impl Unpin for QueryBuilder
impl UnsafeUnpin for QueryBuilder
impl !UnwindSafe for QueryBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more