Audit Log
The audit tool logs every input it receives using the engine’s configured logger.
Because logging is a side-effect that the client doesn’t explicitly request in their GraphQL query, the audit tool is almost always used in conjunction with the force statement to guarantee execution.
Input Fields
Section titled “Input Fields”| Field | Default | Description |
|---|---|---|
level | "info" | The log level. |
Dynamic Fields (Payload & Query Parameters)
Section titled “Dynamic Fields (Payload & Query Parameters)”Any other field is aggregated into a single structured JSON object and sent to the logger.
Example 1: Basic Auditing
Section titled “Example 1: Basic Auditing”Wire any number of inputs to the tool and use force to trigger the execution.
bridge Mutation.createOrder { with std.audit as audit with orderApi as api with input as i with output as o
# 1. Execute the main API call api.product <- i.product
# 2. Wire up the audit payload audit.action = "createOrder" audit.userId <- i.userId audit.orderId <- api.id
# 3. Force the logger to run! force audit
# 4. Map the API response to the client o.id <- api.id}Example 2: Changing the Log Level
Section titled “Example 2: Changing the Log Level”You can override the default log level by statically assigning or dynamically wiring the level field.
bridge Mutation.deleteAccount { with std.audit with input as i
# This will call logger.warn({ action: "deleteAccount", target: ... }, "[bridge:audit]") std.audit.level = "warn"
std.audit.action = "deleteAccount" std.audit.target <- i.accountId
force std.audit}Engine Configuration
Section titled “Engine Configuration”For the audit tool to output anything, you must provide a logger to your execution environment (either to BridgeOptions in the Gateway, or directly to the ExecutionTree in Standalone mode).