Mutation: Record creation
Less than to read
A creation starts with a mutation on a specific node.
For creation, you need to enter a create() section. The create() section must include a data section that describes the JSON payload of the record to create. Lines are in JSON arrays of line structures, but you can also have a single sub-level structure, such as the internal note.
After the data section, there is a section that describes the data to be returned. In this section, the API asks for the document number, the internal ID, and the order date.
The following table displays an example and the result of a mutation to create a record. Some of the fields displayed are not mandatory and others have been omitted.
|
|
If the API call fails, the return payload has an additional error section. For example, this is what happens when your stock site does not exist. The user entered #7000 instead of #700:
{
"errors": [
{
"message": "Site: Record not found: {\"_id\":\"#7000\"}",
"locations": [
{
"line": 4,
"column": 7
}
],
"path": [
"xtremSales",
"salesOrder",
"create"
],
"extensions": {
"code": "data-input-error",
"diagnoses": [
{
"severity": 3,
"message": "Site: Record not found: {\"_id\":\"#7000\"}",
"path": []
}
]
}
}
],
"data": {
"xtremSales": {
"salesOrder": {
"create": null
}
}
},
"extensions": {
"diagnoses": []
}
}