pub struct GraphqlSelect { /* private fields */ }Expand description
GraphQL query builder — produces a query document + variables map.
Construct via GraphqlSelect::new and the chainable with_*
builders, or through the Selectable trait (table.select()). Designed
to be generic in shape: most servers wrap their list field with a
filter arg (where:, find:, …) plus pagination args, and the
renderer handles both dialects shipped here.
Grouping and DISTINCT have no GraphQL spelling: the Selectable
methods for them are no-ops.
Implementations§
Source§impl GraphqlSelect
impl GraphqlSelect
Sourcepub fn with_root_field(self, name: impl Into<String>) -> Self
pub fn with_root_field(self, name: impl Into<String>) -> Self
Set the root field on the Query type (launches).
Sourcepub fn with_operation_name(self, name: impl Into<String>) -> Self
pub fn with_operation_name(self, name: impl Into<String>) -> Self
Name the operation: query <name>(…) { … }.
Sourcepub fn with_dialect(self, dialect: FilterDialect) -> Self
pub fn with_dialect(self, dialect: FilterDialect) -> Self
Pick the dialect conditions render in.
Sourcepub fn with_filter_arg_name(self, name: impl Into<String>) -> Self
pub fn with_filter_arg_name(self, name: impl Into<String>) -> Self
Override the filter argument name (the dialect’s where / find).
Sourcepub fn with_field(self, name: impl Into<String>) -> Self
pub fn with_field(self, name: impl Into<String>) -> Self
Add a terminal (scalar) field to the selection set. A dotted path
(rocket.name) renders as a nested selection.
Sourcepub fn with_root_args(self, args: Value) -> Self
pub fn with_root_args(self, args: Value) -> Self
Literal arguments always passed to the root field. Expects a JSON object; anything else is ignored at render time.
Sourcepub fn with_response_path(self, path: Vec<String>) -> Self
pub fn with_response_path(self, path: Vec<String>) -> Self
Envelope the rows sit inside — ["edges", "node"] wraps the
selection set in edges { node { … } }.
Sourcepub fn with_sub_selection(
self,
name: impl Into<String>,
child: GraphqlSelect,
) -> Self
pub fn with_sub_selection( self, name: impl Into<String>, child: GraphqlSelect, ) -> Self
Add a nested selection set under name, rendered with its own
inline filter and paging arguments.
Sourcepub fn with_condition(self, condition: GraphqlCondition) -> Self
pub fn with_condition(self, condition: GraphqlCondition) -> Self
Add a condition; every condition is ANDed into the filter argument.
Sourcepub fn with_order(self, field: impl Into<String>, order: Order) -> Self
pub fn with_order(self, field: impl Into<String>, order: Order) -> Self
Add a sort key (rendered as order_by: on Hasura only).
Source§impl GraphqlSelect
impl GraphqlSelect
Sourcepub async fn render(&self) -> Result<RenderedQuery>
pub async fn render(&self) -> Result<RenderedQuery>
Produce a (query, variables) pair. Async because conditions
may carry Deferred branches that resolve at fetch time.
Every name spliced into the document is checked against the GraphQL
Name grammar first; an invalid one is an error, never a request.
Sourcepub fn preview(&self) -> String
pub fn preview(&self) -> String
The document render would produce, built synchronously
so it can be shown without sending anything.
Mirrors render arm for arm — same filter, same order, same selection
set, same response envelope — and differs in exactly two ways, both
forced by not being allowed to do any work:
- A deferred condition renders as a
**deferred(...)marker rather than being awaited. Resolving one means asking the caller for a value that only exists mid-fetch. - Pagination is inlined (
limit: 5) instead of going through the$limitvariable, so the document reads standalone. The server is told the same numbers either way.
Everything else is the query that gets sent, and pastes into a GraphQL client as-is.
Source§impl GraphqlSelect
impl GraphqlSelect
Sourcepub fn root_field(&self) -> Option<&str>
pub fn root_field(&self) -> Option<&str>
The root field on the Query type, once set.
Sourcepub fn conditions(&self) -> &[GraphqlCondition]
pub fn conditions(&self) -> &[GraphqlCondition]
The conditions combined into the filter argument.
Sourcepub fn dialect(&self) -> FilterDialect
pub fn dialect(&self) -> FilterDialect
The filter dialect conditions render in.
Trait Implementations§
Source§impl Clone for GraphqlSelect
impl Clone for GraphqlSelect
Source§impl Debug for GraphqlSelect
impl Debug for GraphqlSelect
Source§impl Default for GraphqlSelect
impl Default for GraphqlSelect
Source§impl Expressive<AnyGraphqlType> for GraphqlSelect
impl Expressive<AnyGraphqlType> for GraphqlSelect
Source§fn expr(&self) -> Expression<AnyGraphqlType>
fn expr(&self) -> Expression<AnyGraphqlType>
Expression<T>. Read moreSource§impl Selectable<AnyGraphqlType, GraphqlCondition> for GraphqlSelect
impl Selectable<AnyGraphqlType, GraphqlCondition> for GraphqlSelect
Source§fn set_distinct(&mut self, _distinct: bool)
fn set_distinct(&mut self, _distinct: bool)
No GraphQL spelling: ignored.
Source§fn add_group_by(&mut self, _expression: impl Expressive<AnyGraphqlType>)
fn add_group_by(&mut self, _expression: impl Expressive<AnyGraphqlType>)
No GraphQL spelling: ignored.
Source§fn add_source(
&mut self,
source: impl Into<SourceRef<AnyGraphqlType>>,
_alias: Option<String>,
)
fn add_source( &mut self, source: impl Into<SourceRef<AnyGraphqlType>>, _alias: Option<String>, )
Source§fn add_expression(&mut self, _expression: impl Expressive<AnyGraphqlType>)
fn add_expression(&mut self, _expression: impl Expressive<AnyGraphqlType>)
Source§fn add_where_condition(&mut self, condition: impl Into<GraphqlCondition>)
fn add_where_condition(&mut self, condition: impl Into<GraphqlCondition>)
Source§fn add_order_by(&mut self, order: impl Into<GraphqlCondition>, direction: Order)
fn add_order_by(&mut self, order: impl Into<GraphqlCondition>, direction: Order)
Source§fn set_limit(&mut self, limit: Option<i64>, skip: Option<i64>)
fn set_limit(&mut self, limit: Option<i64>, skip: Option<i64>)
Source§fn clear_fields(&mut self)
fn clear_fields(&mut self)
Source§fn clear_where_conditions(&mut self)
fn clear_where_conditions(&mut self)
Source§fn clear_order_by(&mut self)
fn clear_order_by(&mut self)
Source§fn clear_group_by(&mut self)
fn clear_group_by(&mut self)
Source§fn has_fields(&self) -> bool
fn has_fields(&self) -> bool
Source§fn has_where_conditions(&self) -> bool
fn has_where_conditions(&self) -> bool
Source§fn has_order_by(&self) -> bool
fn has_order_by(&self) -> bool
Source§fn has_group_by(&self) -> bool
fn has_group_by(&self) -> bool
Source§fn is_distinct(&self) -> bool
fn is_distinct(&self) -> bool
Source§fn as_field(&self, _field: impl Into<String>) -> Expression<AnyGraphqlType>
fn as_field(&self, _field: impl Into<String>) -> Expression<AnyGraphqlType>
Source§fn as_count(&self) -> Expression<AnyGraphqlType>
fn as_count(&self) -> Expression<AnyGraphqlType>
Source§fn as_sum(
&self,
column: impl Expressive<AnyGraphqlType>,
) -> Expression<AnyGraphqlType>
fn as_sum( &self, column: impl Expressive<AnyGraphqlType>, ) -> Expression<AnyGraphqlType>
Source§fn as_max(
&self,
column: impl Expressive<AnyGraphqlType>,
) -> Expression<AnyGraphqlType>
fn as_max( &self, column: impl Expressive<AnyGraphqlType>, ) -> Expression<AnyGraphqlType>
Source§fn as_min(
&self,
column: impl Expressive<AnyGraphqlType>,
) -> Expression<AnyGraphqlType>
fn as_min( &self, column: impl Expressive<AnyGraphqlType>, ) -> Expression<AnyGraphqlType>
Source§fn with_source(self, source: impl Into<SourceRef<T>>) -> Selfwhere
Self: Sized,
fn with_source(self, source: impl Into<SourceRef<T>>) -> Selfwhere
Self: Sized,
Self::add_source without alias.Source§fn with_source_as(
self,
source: impl Into<SourceRef<T>>,
alias: impl Into<String>,
) -> Selfwhere
Self: Sized,
fn with_source_as(
self,
source: impl Into<SourceRef<T>>,
alias: impl Into<String>,
) -> Selfwhere
Self: Sized,
Self::add_source with alias.Source§fn with_condition(self, condition: impl Into<C>) -> Selfwhere
Self: Sized,
fn with_condition(self, condition: impl Into<C>) -> Selfwhere
Self: Sized,
Self::add_where_condition.Source§fn with_order(self, order: impl Into<C>, direction: Order) -> Selfwhere
Self: Sized,
fn with_order(self, order: impl Into<C>, direction: Order) -> Selfwhere
Self: Sized,
Self::add_order_by.Source§fn with_field(self, field: impl Into<String>) -> Selfwhere
Self: Sized,
fn with_field(self, field: impl Into<String>) -> Selfwhere
Self: Sized,
Self::add_field.Source§fn with_expression(self, expression: impl Expressive<T>) -> Selfwhere
Self: Sized,
fn with_expression(self, expression: impl Expressive<T>) -> Selfwhere
Self: Sized,
Self::add_expression.Source§fn with_group_by(self, expression: impl Expressive<T>) -> Selfwhere
Self: Sized,
fn with_group_by(self, expression: impl Expressive<T>) -> Selfwhere
Self: Sized,
Self::add_group_by.Source§fn with_distinct(self, distinct: bool) -> Selfwhere
Self: Sized,
fn with_distinct(self, distinct: bool) -> Selfwhere
Self: Sized,
Self::set_distinct.Source§fn with_limit(self, limit: Option<i64>, skip: Option<i64>) -> Selfwhere
Self: Sized,
fn with_limit(self, limit: Option<i64>, skip: Option<i64>) -> Selfwhere
Self: Sized,
Self::set_limit.Auto Trait Implementations§
impl !RefUnwindSafe for GraphqlSelect
impl !UnwindSafe for GraphqlSelect
impl Freeze for GraphqlSelect
impl Send for GraphqlSelect
impl Sync for GraphqlSelect
impl Unpin for GraphqlSelect
impl UnsafeUnpin for GraphqlSelect
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ColumnType for T
Source§impl<T> ExpressionLike for T
impl<T> ExpressionLike for T
Source§fn clone_box(&self) -> Box<dyn ExpressionLike>
fn clone_box(&self) -> Box<dyn ExpressionLike>
Source§impl<T, S> GraphqlOperation<T> for Swhere
S: Expressive<T>,
impl<T, S> GraphqlOperation<T> for Swhere
S: Expressive<T>,
Source§fn eq(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
fn eq(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
field = valueSource§fn ne(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
fn ne(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
field != valueSource§fn gt(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
fn gt(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
field > valueSource§fn gte(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
fn gte(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
field >= valueSource§fn lt(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
fn lt(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
field < valueSource§fn lte(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
fn lte(&self, value: impl Into<AnyGraphqlType>) -> GraphqlConditionwhere
Self: Sized,
field <= valueSource§fn in_<I, V>(&self, values: I) -> GraphqlCondition
fn in_<I, V>(&self, values: I) -> GraphqlCondition
field IN [values...]Source§fn not_in<I, V>(&self, values: I) -> GraphqlCondition
fn not_in<I, V>(&self, values: I) -> GraphqlCondition
field NOT IN [values...]Source§fn like(&self, pattern: impl Into<String>) -> GraphqlConditionwhere
Self: Sized,
fn like(&self, pattern: impl Into<String>) -> GraphqlConditionwhere
Self: Sized,
field LIKE pattern — case-sensitive substring match.Source§fn ilike(&self, pattern: impl Into<String>) -> GraphqlConditionwhere
Self: Sized,
fn ilike(&self, pattern: impl Into<String>) -> GraphqlConditionwhere
Self: Sized,
field ILIKE pattern — case-insensitive substring match.Source§fn is_null(&self) -> GraphqlConditionwhere
Self: Sized,
fn is_null(&self) -> GraphqlConditionwhere
Self: Sized,
field IS NULLSource§fn is_not_null(&self) -> GraphqlConditionwhere
Self: Sized,
fn is_not_null(&self) -> GraphqlConditionwhere
Self: Sized,
field IS NOT NULLSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more