Skip to content

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.

FieldDefaultDescription
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.

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
}

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
}

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).