Liquid console
Mechanic's Liquid console is available in the footer of every page of the Mechanic Shopify app. It's a useful scratchpad for testing Mechanic Liquid, without having to think about the output restrictions of task previews. The console includes information about the final rendering context for each Liquid submission, which can be useful in understanding how Mechanic Liquid works.
Unlike task previews, the Liquid console does permit access to the Shopify Admin API, with a limit of 10 requests per Liquid submission.
The Liquid console has much tighter restrictions on memory limits than actual task runs. If you run into a memory limit error, try testing your code in a new task subscribing to mechanic/user/trigger, allowing you to experiment with your code in Mechanic's full runtime environment.

Context

Liquid code is always rendered in a certain context, which includes some information going in, and which may contain additional information afterward.
Mechanic's Liquid console includes information about the final rendering context, as inspected after the render. This includes...
  • ​Environment variables, as set by the Mechanic platform ahead of time
  • Scope variables, as set by the user in their submitted Liquid code during rendering
  • Information about the way the user's Liquid code interacted with the Shopify API during rendering

Events

When viewing a specific event in the Mechanic app, the Liquid rendering context bears the current event in mind. This means that variables available are similar to those given to any tasks that responded to that event: both the event variable and the event's subject variables are available to the console.
Because of this, the Liquid console can be used for examining what a task had access to at the moment of any given event. For a shopify/orders/create event, for example, one might use {% log order.line_items[0] %} to see the contents of an order's first line item.
Looking at a child event? Try using {% log event.parent %} in the console to inspect data available from the parent. Or, to examine data from an ancestor event further back, try {% log event.parent.parent %}.
​
Copy link
Edit on GitHub