Adding nodes from palette gives negative key to the new node

Hello im creating a graph in angular with a palette. when i add new nodes from the palette the key gets negative value and i can connect it with other nodes, but if i generate a new number and assign it as a key of the new node then the node can not connect with other nodes.

here is the new node when i drag items from palette

    "fromPallete": false,
    "AssetType": "servers",
    "text": "Database",
    "color": "white",
    "points": [],
    "__gohashid": 5273,
    "key": -1,
    "loc": {
        "x": 346.2028812589194,
        "y": -149.72098196890585,
        "v": false

and here is the code that i change the key of the node(the above object is generated without my node.key assign):

  this.diagram.addDiagramListener('ExternalObjectsDropped', (e) => {
       const node = this.diagram.selection.first()?.data;
       node.key = generateIntID(18);
       this.graphService.setNodeData({ open: false });

any ideas why i cant give it my own key and create connections from that node or how i can change the negative default keys?

Solved it with the use of this.diagram.model.setKeyForNodeData(node,Math.abs(Math.floor(Math.random() * 999999999)))

instead of node.key =