Fluent Commerce Logo
Docs

Dynamic Mutations

Essential knowledgeCore knowledge to understand Fluent Commerce

Intended Audience:

Technical User

Authors:

Kirill Gaiduk, Valery Kornilovich

Changed on:

19 Mar 2026

Overview

`DynamicUpdateMutation` automatically derives the correct update Mutation for the primary Entity based on the `RulesetContext` and then performs the update on one or more fields.

Key points

  • Automatic Mutation Selection: GraphQL mutations are automatically selected from the `RulesetContext` based on entity type.
  • Flexible Field Updates: Update single fields or multiple fields in bulk using simple key-value pairs.
  • Type-Based Safety: Use POJO classes for strongly-typed updates with automatic field derivation.
  • Runtime Validation: Built-in validation ensures only valid fields are included in mutations.
  • Universal Application: Works across different entity types without requiring entity-specific mutation code.
Here is a collection of common scenarios for the Dynamic Mutations usage:

Field-based Updates

Fields can be updated directly by name. You can:
  • Update a single field 
  • Provide multiple fields in a `Map<String, Object>` for bulk updates

Type-based Update

For improved type safety, `DynamicUpdateMutation` can also recursively derive update fields from a defined POJO. This allows you to work with strongly typed objects while still benefiting from dynamic field updates, ensuring both flexibility and safety in your Rule logic.

Error Handling

The `DynamicUpdateMutation` provides built-in error handling:This ensures that your mutations are robust and handle edge cases gracefully.

Complete Examples

Example 1: Generic Field Setter Rule

This rule demonstrates how to create a reusable field setter that works for any entity type:

Example 2: Complex Object Update

This example shows how to update complex nested objects using type-based mutations: