Skip to content
Developerhome

Mutations

  Less than to read

It is possible to apply mutations to custom fields.

A JSON field must be used to apply a mutation on a custom field.

In the case of a bulk update mutation, the system will be responsible for merging the values.

The following table displays the result of a query before and after a mutation is applied to a custom field:

{ 
  xtremMasterData{ 
    item{ 
      query (filter: "{_customData: { _ne: null}}"){ 
        edges { 
          node { 
            id 
            _id 
            _customData 
          }
        } 
      } 
    } 
  } 
} 
{ 
  "data": { 
    "xtremMasterData": { 
      "item": { 
        "query": { 
          "edges": [ 
            { 
              "node": { 
                "id": "PIE_BLUEBERRY", 
                "_id": "161", 
                "_customData": "{\"rating\":35,\"marketingDate\":\"2023-08-17\"}" 
              } 
            }
          ] 
        }
      }
    }
  }, 
  "extensions": { 
    "diagnoses": [] 
  }
} 
mutation { 
    xtremMasterData { 
        item { 
            update ( 
              data:{ 
                _id:"161", 
                _customData: "{\"rating\":28}" 
              }
            ) 
          { 
            rate:_customData(selector:"rating") 
          } 
        } 
    }
} 
{ 
  "data": { 
    "xtremMasterData": { 
      "item": { 
        "update": { 
          "rate": "28" 
        } 
      } 
    } 
  }, 
  "extensions": { 
    "diagnoses": [] 
  } 
} 
{ 
  xtremMasterData{ 
    item{ 
      query (filter: "{_customData: { _ne: null}}"){ 
        edges { 
          node { 
            id 
            _id 
            _customData 
          } 
        } 
      } 
    } 
  }
} 
{ 
  "data": { 
    "xtremMasterData": { 
      "item": { 
        "query": { 
          "edges": [ 
            { 
              "node": { 
                "id": "PIE_BLUEBERRY", 
                "_id": "161", 
                "_customData": "{\"rating\":28,\"marketingDate\":\"2023-08-17\"}" 
              } 
            } 
          ]
        }
      }
    }
  }, 
  "extensions": { 
    "diagnoses": [] 
  }
} 

It is also possible to apply bulk mutations to custom fields.

The following table displays examples of queries where a bulk mutation is applied to a custom field:

mutation { 
    xtremMasterData { 
        item { 
             bulkUpdate( 
              data:{ 
                volume:20, 
                _customData: "{\"suggestedPrice\":10}", 
              } 
              filter : "{stockUnit:{name:'Each'}}" 
            ) 
        } 
    } 
} 
{ 
  "data": { 
    "xtremMasterData": { 
      "item": { 
        "bulkUpdate": true 
      } 
    } 
  }, 
  "extensions": { 
    "diagnoses": [] 
  } 

} 
mutation { 
    xtremMasterData { 
        item { 
             bulkUpdate( 
              data:{ 
                volume:10, 
                _customData: "{\"contractDate\":\"2023-05-29\"}", 
              } 
              filter : "{stockUnit:{name:'Each'}}" 
            ) 
        } 
    } 
} 
{ 
  "data": { 
    "xtremMasterData": { 
      "item": { 
        "bulkUpdate": true 
      } 
    } 
  }, 
  "extensions": { 
    "diagnoses": [] 
  } 
} 
mutation { 
    xtremMasterData { 
        item { 
             bulkUpdate( 
              data:{ 
              _customData: null, 
              } 
              filter : "{stockUnit:{name:'Each'}}" 
            ) 
        } 
    } 
} 
{ 
  "data": { 
    "xtremMasterData": { 
      "item": { 
        "bulkUpdate": true 
      } 
    } 
  },
  "extensions": { 
    "diagnoses": [] 
  } 
}