Expand description
Runtime query executor - executes compiled queries.
§Architecture
The runtime loads a CompiledSchema and executes incoming GraphQL queries by:
- Parsing the GraphQL query
- Matching it to a compiled query template
- Binding variables
- Executing the pre-compiled SQL
- Projecting JSONB results to GraphQL response
§Key Concepts
- Zero runtime compilation: All SQL is pre-compiled
- Pattern matching: Match incoming query structure to templates
- Variable binding: Safe parameter substitution
- Result projection: JSONB → GraphQL JSON transformation
§Example
// Requires: a compiled schema file and a live PostgreSQL database.
// See: tests/integration/ for runnable examples.
use fraiseql_core::runtime::Executor;
use fraiseql_core::schema::CompiledSchema;
use fraiseql_core::db::postgres::PostgresAdapter;
use std::sync::Arc;
// Load compiled schema
let schema = CompiledSchema::from_json(schema_json, false)?;
// Create executor with a concrete adapter implementation
let adapter = Arc::new(PostgresAdapter::new("postgresql://localhost/mydb").await?);
let executor = Executor::new(schema, adapter);
// Execute GraphQL query
let query = r#"query { users { id name } }"#;
let result = executor.execute(query, None).await?;
println!("{}", result);Re-exports§
pub use after_mutation::AfterMutationObserver;pub use after_mutation::CommittedMutation;pub use after_mutation::current_dispatch_depth;pub use after_mutation::dispatched_at;pub use aggregation::AggregationSqlGenerator;pub use aggregation::ParameterizedAggregationSql;pub use field_filter::FieldAccessResult;pub use field_filter::can_access_field;pub use field_filter::can_reference_field;pub use field_filter::classify_field_access;pub use field_filter::filter_fields;pub use jsonb_strategy::JsonbOptimizationOptions;pub use jsonb_strategy::JsonbStrategy;pub use mutation_result::MutationErrorShapeCheck;pub use mutation_result::mutation_error_shape_violations;pub use query_function::QueryFunctionRequest;pub use query_function::QueryFunctionResolver;pub use query_tracing::QueryExecutionTrace;pub use query_tracing::QueryPhaseSpan;pub use query_tracing::QueryTraceBuilder;pub use query_tracing::create_phase_span;pub use query_tracing::create_query_span;pub use sql_logger::SqlOperation;pub use sql_logger::SqlQueryLog;pub use sql_logger::SqlQueryLogBuilder;pub use sql_logger::create_sql_span;pub use subscription::ActiveSubscription;pub use subscription::DeliveryResult;pub use subscription::KafkaAdapter;pub use subscription::KafkaConfig;pub use subscription::KafkaMessage;pub use subscription::SubscriptionError;pub use subscription::SubscriptionEvent;pub use subscription::SubscriptionId;pub use subscription::SubscriptionManager;pub use subscription::SubscriptionOperation;pub use subscription::SubscriptionPayload;pub use subscription::TransportAdapter;pub use subscription::TransportManager;pub use subscription::WebhookAdapter;pub use subscription::WebhookConfig;pub use subscription::WebhookPayload;pub use subscription::extract_rls_conditions;pub use subscription::protocol;pub use tenant_enforcer::TenantEnforcer;pub use window::WindowSql;pub use window::WindowSqlGenerator;
Modules§
- after_
mutation - The engine’s notice that a mutation committed (#1340, #1440).
- aggregation
- Runtime Aggregation SQL Generation Module
- cascade
- Cascade-spec error classification.
- field_
filter - Field-level RBAC filtering for runtime field projection.
- input_
validator - Input validation for GraphQL mutations and queries.
- jsonb_
strategy - JSONB field handling strategy selection
- mutation_
result - Mutation response parser for
app.mutation_responsecomposite rows. - partial_
period - Partial-period awareness for pre-aggregated time-series views.
- query_
function - Resolution of a function-backed root query field (#1329).
- query_
tracing - Query execution tracing and observability instrumentation.
- relay
- Relay cursor encoding and decoding.
- sql_
logger - Structured SQL query logging and tracing.
- subscription
- Subscription runtime for event-driven GraphQL subscriptions.
- tenant_
enforcer - Multi-tenancy enforcement layer.
- window
- Window Function SQL Generation
Structs§
- Aggregate
Query Parser - Aggregate query parser
- Aggregation
Projector - Aggregation result projector
- Bulk
Result - Result of a bulk REST operation (collection-level PATCH/DELETE).
- Cascade
Limits - Response-size limits for the typed cascade surface, per the graphql-cascade
spec’s security requirements (
specification/16_security.md). - Count
Selection - A relationship whose related rows are counted, for each row of the level above it.
- Embed
Selection - A relationship to embed into each row of the level above it.
- Execution
Context - Execution context for query cancellation support.
- Execution
Plan - Execution plan for a query.
- Executor
- Query executor - executes compiled GraphQL queries.
- Explain
Plan - Explanation of a query’s execution plan, returned by the explain endpoint.
- Explain
Result - Result of
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)run against a view with real parameter values. - Field
Mapping - Field mapping for projection with alias support.
- Mutation
Execution - Core mutation execution logic.
- Projection
Mapper - Projection mapper - maps JSONB fields to GraphQL selection set.
- Query
Match - A matched query with extracted information.
- Query
Matcher - Query pattern matcher.
- Query
Planner - Query planner - selects optimal execution strategy.
- Result
Projector - Result projector - high-level result transformation.
- RowRead
- A row-shaped read and the projection it was actually read with (#1351).
- Runtime
Config - Runtime configuration for the FraiseQL query executor.
- Stamp
Contract - What a mutation’s function may stamp in its
entity_typecolumn (rulings AA 1, AG 2). - Streamed
RowRead - The streamed twin of
RowRead, carrying its projection for the same reason. - Subscription
Plan - A subscription planned for one subscriber: what each event is served as.
- Window
Projector - Window function result projector.
- Window
Query Parser - Window query parser
- Write
Selections - A write’s result selection set, guaranteed non-empty.
Functions§
- coerce_
pagination_ arg - One definition of “is this argument a row count”, re-exported so every
transport that reads
limit/offset/first/lastfails closed the same way (#1197). A second, lenient reading of the same argument is how the bound got dropped in the first place. One definition of “is this argument a row count”, re-exported so every transport that readslimit/offset/first/lastfails closed the same way (#1197). A second, lenient reading of the same argument is how the bound got dropped in the first place. One definition of “is this argument a row count”, re-exported so every transport that readslimit/offset/first/lastfails closed the same way (#1197). A second, lenient reading of the same argument is how the bound got dropped in the first place. Reject a pagination argument that exceeds the configured maximum page size. - collect_
variable_ references - Every variable referenced by the executed operation, in document order, without duplicates.
- extract_
root_ field_ names - Returns the response key (alias or field name) for every root-level selection.
- is_
multi_ root - Returns
truewhen the query has more than one root field selection. - multi_
root_ queries_ total - Total multi-root GraphQL queries dispatched via the parallel execution path.
- mutation_
contract_ errors - How many writes this process refused as a mutation contract error — an off-contract or
ambiguous
entity_typestamp, on either outcome (rulings AA 1, AG 3) — each rolled back. - mutation_
return_ selections - The selection set a transport with no selection set of its own projects a write through: every scalar field the mutation’s declared return type names.
- page_
size_ precedence - Resolve the top-level page-size ceiling (#421) by precedence.
- project_
entity - Project an entity-shaped JSONB value into a GraphQL response object, mirroring the query path’s SQL projection exactly.
- project_
nested_ lists - #489 — recase + project nested LIST-of-object fields left raw by the SQL projection.
- resolve_
session_ variables - Resolve session variable mappings against the current security context.
- stamp_
nested_ typenames - Stamp
__typenameon the nested single objects whose selection asked for it. - suggest_
similar - Return candidates from
haystackwhose edit distance toneedleis ≤ 2. - suppressed_
subscription_ events - How many events subscription plans have suppressed since the process started.
- validate_
argument_ names - Check that every argument in
providedis one ofaccepted. - validate_
argument_ values - Check the value written at each of
providedagainst the typedeclaredgives that argument (§ 5.6.1), and the declared type of each variable used there against the same (§ 5.8.5). - validate_
enum_ argument_ literals - Adjudicate enum membership for the literals a document writes at a field’s arguments (#1362).
- validate_
enum_ argument_ values - Adjudicate enum membership for the values written at a field’s arguments, from a resolved argument map (#1362).
- validate_
enum_ variable_ values - Adjudicate enum membership for supplied variable values against their own declarations — § 6.1.2, for enums (#1362).
- validate_
variable_ types - Check that every variable definition names a type the schema publishes as an input type (GraphQL § 5.8.2).
- validate_
variable_ uses - Check that every variable referenced by the operation is defined by it.
- validate_
variable_ values - Check each supplied variable against the type its operation declares, and refuse a non-null variable that carries no value at all (§ 6.1.2).
- validate_
variables_ used - Check that every variable the operation defines is also used by it (GraphQL § 5.8.4).
Type Aliases§
- Json
RowStream - Projected response rows delivered as the database produces them (#958).
- Root
Error Renderer - Renders an engine error as a GraphQL
errorsentry, without itspath(seeRuntimeConfig::root_error_renderer).