General Principles for Rules
Author:
Randy Chan
Changed on:
3 Nov 2023
Overview
Understand what are some general Rule principles.
Key points
- Fluent uses jsonPath, which is a period-separated string that describes a "path" between the entity being processed and a field on it or a related entity.
- In essence, this category of rules understands how to generate dynamic queries.
- There are some helpers for traversing connection types, edges, and node fields, which will be automatically skipped, for example, is equivalent to
`items.0.currency`
`items.edges.0.node.currency`
JsonPath Props
Many of the rules in the core module accept a prop typed as a jsonPath, which is a period-separated string that describes a "path" between the entity being processed and a field on it or a related entity.
In essence, this category of rules understands how to generate dynamic queries to maximize flexibility across domains and use cases. In most cases, the value/s loaded via this dynamic query will be compared against another rule prop as described by the rule name and description.
For example, fields on or related to the Order entity could be accessed with the following paths:
Path | Description |
| Use the state field of the Order. |
| Use the delivery type field of the Fulfillment Choice related to the Order. |
| Use the currency value of the first item of the Order. |
| Use the value of a custom attribute of the Order. |
Additionally, properties of the event can be referenced with the
`event.`
Path | Description |
| Use the entity subtype from the event. |
| Use the value of a custom event attribute. |
| As above, as long as the attribute name doesn't clash with a standard attribute field. |
Finally, there are some helpers to simplify specific use cases: - when traversing connection types, edges, and node fields will be automatically skipped over even if they're not added to the path, e.g., the
`items.0.currency`
`items.edges.0.node.currency`
`items.first.currency`
`items.last.currency`
`byName`
`attributes.byName.promoCode`