com.walmartlabs.lacinia

execute

(execute schema query variables context)(execute schema query variables context options)

Given a compiled schema and a query string, attempts to execute it.

Returns a result map with up-to two keys: :data is the main result of the execution, and :errors are any errors generated during execution.

In the case where there’s a parse or validation problem for the query, just the :errors key will be present.

schema
GraphQL schema (as compiled by com.walmartlabs.lacinia.schema/compile).
query
Input query string to be parsed and executed.
variables
compile-time variables that can be referenced inside the query using the $variable-name production.
context (optional)
Additional data that will ultimately be passed to resolver functions.
options (optional)
Additional options to control execution.

Options:

:operation-name
Identifies which operation to execute, when the query specifies more than one.
:timeout-ms
Timeout for the operation. Defaults to 0, for no timeout at all.
:timeout-error
Error map used if a timeout occurs.
Default is {:message "Query execution timed out."}.

This function parses the query and invokes execute-parsed-query.

When a GraphQL query contains variables, the values for those variables arrive seperately; for example, a JSON request may have the query in the “query” property, and the variables in the “variables” property.

The values for those variables are provided in the variables parameter. The keys are keyword-ized names of the variable (without the leading ‘$’); if a variable is named $user_id in the query, the corresponding key should be :user_id.

The values in the variables map should be of a type matching the variable’s declaration in the query; typically a string or other scalar value, or a map for a variable of type InputObject.

execute-parsed-query

(execute-parsed-query parsed-query variables context)(execute-parsed-query parsed-query variables context options)

Prepares a query, by applying query variables to it, resulting in a prepared query which is then executed.

Returns a result map (with :data and/or :errors keys), or an exception if execution failed.

Options as per execute.

execute-parsed-query-async

added in 0.16.0

(execute-parsed-query-async parsed-query variables context)

Prepares a query, by applying query variables to it, resulting in a prepared query which is then executed.

Returns a ResolverResult that will deliver the result map, or an exception.