mochi/batch
Types
Configuration for batch execution
pub type BatchConfig {
BatchConfig(
max_batch_size: Int,
continue_on_error: Bool,
allow_parallel: Bool,
)
}
Constructors
-
BatchConfig( max_batch_size: Int, continue_on_error: Bool, allow_parallel: Bool, )Arguments
- max_batch_size
-
Maximum number of queries allowed in a single batch
- continue_on_error
-
Whether to continue executing remaining queries if one fails
- allow_parallel
-
Whether to allow parallel execution (when possible)
A single request in a batch
pub type BatchRequest {
BatchRequest(
query: String,
variables: option.Option(dict.Dict(String, dynamic.Dynamic)),
operation_name: option.Option(String),
)
}
Constructors
-
BatchRequest( query: String, variables: option.Option(dict.Dict(String, dynamic.Dynamic)), operation_name: option.Option(String), )Arguments
- query
-
The GraphQL query string
- variables
-
Optional variables for the query
- operation_name
-
Optional operation name to execute
Result of a batch execution
pub type BatchResult {
BatchResult(
results: List(executor.ExecutionResult),
all_succeeded: Bool,
failure_count: Int,
)
}
Constructors
-
BatchResult( results: List(executor.ExecutionResult), all_succeeded: Bool, failure_count: Int, )Arguments
- results
-
Results in the same order as requests
- all_succeeded
-
Whether all queries succeeded
- failure_count
-
Number of failed queries
Values
pub fn execute_batch(
schema_def: schema.Schema,
requests: List(BatchRequest),
config: BatchConfig,
ctx: schema.ExecutionContext,
) -> BatchResult
Execute a batch of requests
pub fn execute_with_operation_name(
schema_def: schema.Schema,
document: @internal Document,
root_value: option.Option(dynamic.Dynamic),
ctx: schema.ExecutionContext,
variables: dict.Dict(String, dynamic.Dynamic),
operation_name: option.Option(String),
) -> executor.ExecutionResult
Execute a query with a specific operation name selected This is the core function for operation selection in batched queries
pub fn full_request(
query: String,
variables: dict.Dict(String, dynamic.Dynamic),
operation_name: String,
) -> BatchRequest
Create a full batch request
pub fn parse_batch_request(
value: dynamic.Dynamic,
) -> Result(BatchRequest, String)
Parse a batch request from a dynamic value (e.g., from JSON)
pub fn parse_batch_requests(
value: dynamic.Dynamic,
) -> Result(List(BatchRequest), String)
Parse multiple batch requests from a dynamic list
pub fn request_with_operation(
query: String,
operation_name: String,
) -> BatchRequest
Create a batch request with operation name
pub fn request_with_variables(
query: String,
variables: dict.Dict(String, dynamic.Dynamic),
) -> BatchRequest
Create a batch request with variables
pub fn with_continue_on_error(
config: BatchConfig,
continue: Bool,
) -> BatchConfig
Configure whether to continue on error
pub fn with_max_batch_size(
config: BatchConfig,
size: Int,
) -> BatchConfig
Set maximum batch size
pub fn with_parallel_execution(
config: BatchConfig,
parallel: Bool,
) -> BatchConfig
Configure parallel execution