pub struct GraphqlSelect {Show 14 fields
pub root_field: Option<String>,
pub operation_name: Option<String>,
pub fields: Vec<String>,
pub root_args: Option<Value>,
pub response_path: Vec<String>,
pub sub_selections: Vec<(String, GraphqlSelect)>,
pub conditions: Vec<GraphqlCondition>,
pub sort: Vec<(String, Order)>,
pub group_by: Vec<String>,
pub limit: Option<i64>,
pub skip: Option<i64>,
pub distinct: bool,
pub dialect: FilterDialect,
pub filter_arg_name: Option<String>,
}Expand description
GraphQL query builder — produces a query document + variables map.
Construct via GraphqlSelect::new() and the chainable builders, or
via Selectable::with_* methods. 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 we ship with.
Fields§
§root_field: Option<String>Root field on the Query type — launches, usersList, etc.
operation_name: Option<String>Optional operation name (e.g. query GetLaunches { … }).
fields: Vec<String>Selected fields. A dotted path (run.commit.hash) groups into a
nested selection set at render time, so a schema that nests its
scalars needs no relation machinery to read them.
root_args: Option<Value>Literal arguments always passed to the root field — the mandatory
input: {} on Spacelift’s searchRuns(input: SearchInput!), say.
Rendered inline alongside any filter/pagination arguments.
response_path: Vec<String>Envelope the rows sit inside, e.g. ["edges", "node"] for a Relay
connection. The selection set is wrapped in these on the way out
and the response is unwrapped through them on the way back, so the
two can never drift apart.
sub_selections: Vec<(String, GraphqlSelect)>Nested selection sets for relationship traversal. Built up by
the Phase 6 with_many/with_one paths.
conditions: Vec<GraphqlCondition>Conditions combined into the filter argument.
sort: Vec<(String, Order)>Ordering specification. Hasura renders these as order_by:;
other dialects ignore them (or error) until the schema map
provides a per-table override.
group_by: Vec<String>GROUP BY fields. Most GraphQL servers don’t expose grouping at
the query level — we record these for round-trip and let the
renderer decide whether to surface them.
limit: Option<i64>LIMIT. Emitted as a $limit: Int variable.
skip: Option<i64>Offset. Emitted as a $offset: Int variable.
distinct: boolDistinct flag — meaningful only when the schema supports it
(Hasura’s distinct_on:). Plumbed through but ignored by the
default renderer until a per-dialect path is added.
dialect: FilterDialectFilter dialect — drives how conditions get rendered into a
GraphQL argument. Defaults to Generic so the cheapest schemas
work without configuration.
filter_arg_name: Option<String>Override for the filter argument name. Defaults to where
(Hasura) or find (Generic).
Implementations§
Source§impl GraphqlSelect
impl GraphqlSelect
pub fn with_root_field(self, name: impl Into<String>) -> Self
pub fn with_operation_name(self, name: impl Into<String>) -> Self
pub fn with_dialect(self, dialect: FilterDialect) -> Self
pub fn with_filter_arg_name(self, name: impl Into<String>) -> Self
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.
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 sub-selection — used for nested relationships in Phase 6.
pub fn with_condition(self, condition: GraphqlCondition) -> Self
pub fn with_order(self, field: impl Into<String>, order: Order) -> Self
pub fn with_limit(self, limit: Option<i64>, skip: Option<i64>) -> Self
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.
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
Trait Implementations§
Source§impl Clone for GraphqlSelect
impl Clone for GraphqlSelect
Source§fn clone(&self) -> GraphqlSelect
fn clone(&self) -> GraphqlSelect
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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 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 set_distinct(&mut self, distinct: bool)
fn set_distinct(&mut self, distinct: bool)
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 add_group_by(&mut self, expression: impl Expressive<AnyGraphqlType>)
fn add_group_by(&mut self, expression: impl Expressive<AnyGraphqlType>)
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