Write extensions
BNXT GraphQL schema extensions for data model extensions writes are documented in this section.
There is no difference between performing mutation operations on the core model or a model extension. However, it is recommended that you use the extensions schema for DMEs only.
Writing extension columns
When entering input values for extension columns, you must specify the column name and its value. For this, a special type called InputValueExtension is used. This type has the following fields:
| Field | Type | Description |
|---|---|---|
| column | String! | Name of the column |
| integerValue | Int | An integer value |
| stringValue | String | A string value |
| decimalValue | Decimal | A decimal value |
| booleanValue | Boolean | A boolean value |
| dateValue | Date | A date value |
| timeValue | String | A time value |
| timestampValue | DateTime | A timestamp value |
The column field is mandatory and specifies the name of the extension column. The other fields are optional and represent the value to be set for the column. Only one of these value fields should be provided per input. If more than one is provided, an error will be returned.
Here is an example of how to create an order and line both using extensions:
mutation create_order($cid :Int!)
{
useCompany(no : $cid)
{
order_create(values : [
{
extensions : [
{
column : "customerNo",
integerValue : 10010
}
]
orderLines : [
{
productNo : "103",
extensions : [
{
column : "quantity",
integerValue : 2
}
]
}
]
}
])
{
affectedRows
items
{
orderNo
customerNo
joindown_OrderLine_via_Order
{
items
{
orderNo
lineNo
productNo
quantity
}
}
}
}
}
}{
"data": {
"useCompany": {
"order_create": {
"affectedRows": 1,
"items": [
{
"orderNo": 2913,
"customerNo": 10010,
"joindown_OrderLine_via_Order": {
"items": [
{
"orderNo": 2913,
"lineNo": 1,
"productNo": "103",
"quantity": 2
}
]
}
}
]
}
}
}
}Updating extension columns
The syntax for updating extension columns is similar to that of writing them. You need to specify the column name and the new value using the InputValueExtension type. Filters are written in the same way as for reads.
Here is an example of how to update an order using extensions syntax:
mutation update_order($cid :Int!, $ono : Int!)
{
useCompany(no : $cid)
{
order_update(
filters : [
{
extensions : {
column : "orderNo",
integerValue : {_eq : $ono}
}
}
]
values : [
{
extensions : [
{
column : "Name",
stringValue : "Lars Olafson"
}
]
}
]
)
{
affectedRows
items
{
orderNo
name
}
}
}
}{
"data": {
"useCompany": {
"order_update": {
"affectedRows": 1,
"items": [
{
"orderNo": 2913,
"name": "Lars Olafson"
}
]
}
}
}
}Deleting with filter extensions
To delete data from an existing table using fileters on extension columns, you can define filters in the same way as for updating values.
The following example shows how to delete records from the order line and order tables using filter extensions for the orderNo column:
mutation delete_order($cid : Int!, $ono : Int!)
{
useCompany(no : $cid)
{
orderLine_delete(filter : {
extensions : {
column : "orderNo",
integerValue : {_eq : $ono}
}
})
{
affectedRows
}
order_delete(filter : {
extensions : {
column : "orderNo",
integerValue : {_eq : $ono}
}
})
{
affectedRows
}
}
}{
"data": {
"useCompany": {
"orderLine_delete": {
"affectedRows": 1
},
"order_delete": {
"affectedRows": 1
}
}
}
}Writing extension tables
In order to write table to an exentension table, you need to use the table_create field. This is similar to existing table create fields, such as order_create or batch_create. However, in this case, the fields called extensions are missing from the schema.
A mutation to create a new order may look like this:
mutation create_orders($cid :Int!)
{
useCompany(no : $cid)
{
table_create(
name : "order",
values : [
[
{
column : "customerNo",
integerValue : 10010
},
{
column : "orderType",
integerValue : 6
}
],
[
{
column : "customerNo",
integerValue : 10002
},
{
column : "orderType",
stringValue : 1
}
]
])
{
affectedRows
items
{
orderNo : integerValue
customerNo : integerValue
orderType : integerValue
}
}
}
}{
"data": {
"useCompany": {
"table_create": {
"affectedRows": 2,
"items": [
{
"orderNo": 2913,
"customerNo": 10010,
"orderType": 6,
},
{
"orderNo": 2914,
"customerNo": 10002,
"orderType": 1,
}
]
}
}
}
}Updating extension tables
In order to update records in an extension table, you need to use the table_update field. This is similar to existing table update fields, such as order_update or batch_update. However, in this case, the fields called extensions are missing from the schema.
In the following examples, two orders are updated with a single request. One filter and one update value is specified for each order.
mutation update_order($cid :Int!, $ono1 : Int!, $ono2 : Int!, $cn : String!, $val1 : String!, $val2 : String!)
{
useCompany(no : $cid)
{
table_update(
name : "order",
filters : [
{
column : "orderNo",
integerValue : {_eq : $ono1}
},
{
column : "orderNo",
integerValue : {_eq : $ono2}
}
]
values : [
{
column : "Name",
stringValue : "Lars Olafson"
},
{
column : "Name",
stringValue : "Olaf Larson"
}
]
)
{
affectedRows
items
{
orderNo : integerValue
name : stringValue
}
}
}
}{
"data": {
"useCompany": {
"table_update": {
"affectedRows": 2,
"items": [
{
"orderNo": 2913,
"name": "Lars Olafson"
},
{
"orderNo": 2914,
"name": "Olaf Larson"
}
]
}
}
}
}Deleting extension tables
The operation of deleting records from extension tables is done using the table_delete field. This is similar to existing table delete fields, such as order_delete or batch_delete. Again, as in the previous cases, the fields called extensions are missing from the schema.
Here is an example of deleting two orders from the Order table:
mutation delete_order($cid : Int!, $ono1 : Int!, $ono2 : Int!)
{
useCompany(no : $cid)
{
table_delete(
name : "order",
filter : {
column : "orderNo",
integerValue : {_in : [$ono1, $ono2]}
}
)
{
affectedRows
}
}
}{
"data": {
"useCompany": {
"table_delete": {
"affectedRows": 2
}
}
}
}