GraphApplyEdits

AMD: require(["esri/rest/knowledgeGraph/GraphApplyEdits"], (GraphApplyEdits) => { /* code goes here */ });
ESM: import GraphApplyEdits from "@arcgis/core/rest/knowledgeGraph/GraphApplyEdits.js";
Class: esri/rest/knowledgeGraph/GraphApplyEdits
Inheritance: GraphApplyEdits Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25
beta

This class defines entities and relationships to add, delete, and update in a knowledge graph service's graph resource. Use entityUpdates or relationshipUpdates to change property values.

Note

  • The user must have sufficient privileges to edit content, and editing must be enabled for the knowledge graph service for this operation to be successful.
See also
Examples
// add a new `Supplier` entity
require([
  "esri/rest/knowledgeGraphService",
  "esri/rest/knowledgeGraph/Entity",
  "esri/rest/knowledgeGraph/GraphApplyEdits"
], (knowledgeGraphModule, Entity, GraphApplyEdits) => {
  const newEntity = new Entity({
    typeName: "Supplier",
    properties: {
      Name: "Supplier 5",
      EmployeeCount: 681
    }
  });

  KnowledgeGraphModule.executeApplyEdits(
    graph,
    new GraphApplyEdits({
       entityAdds: [newEntity]
     })
  ).then((editResult) => {
     console.log("Graph Add Result", editResult);
   });
});
// add multiple new items
const newEntity = new Entity({
  typeName: "Supplier",
  properties: {
    Name: "Supplier 5",
    EmployeeCount: 681
  },
});

const newRelationship = new Relationship({
  typeName: "buys_part",
  properties: {
    quantity: 5000
  },
  // origin and destination entities must already exist in the graph
  originId: "{AN4E4G85-41F1-49A4-8412-CACCC9906E88}",
  destinationId: "{9D2D6AFD-41F1-49A4-8412-1DGR8E5D6S1G4}"
});

KnowledgeGraphModule.executeApplyEdits(graph, {
   entityAdds: [newEntity],
   relationshipAdds: [newRelationship]
})
.then((editResult) => {
  console.log("Graph Add Result", editResult);
});
// update existing records
const updateEntity = new Entity({
  typeName: "Supplier",
  // update the EmployeeCount from 681 to 685
  properties: {
    Name: "Supplier 5",
    EmployeeCount: 685
  },
  id:"{G1E5G3D4-41F1-49A4-8412-1S5GE8S4D5S1G}" //id of entity already in knowledge graph
});

const updateRelationship = new Relationship({
  typeName: "buys_part",
  // update the quantity from 5000 to 5500
  properties: {
    quantity: 5500
  },
  id: "{MSIGESNG-A1F5-1A8F-3W5F-15A8W4F3S5F8W}" //id of relationship already in knowledge graph
});

KnowledgeGraphModule.executeApplyEdits(graph, {
   entityUpdates: [updateEntity],
   relationshipUpdates: [updateRelationships]
})
.then((editResult) => {
   console.log("Graph Update Result", editResult);
});
// delete existing records
KnowledgeGraphModule.executeApplyEdits(graph, {
   entityDeletes: [{
     typeName: "Supplier",
     ids: ["{AMGIE541G-41F1-49A4-8412-CACCC9906E88}", "{HNWIGHE15-WH52-2GE6-1A5W-A1F8W4FS3A1S5}"]
   },{
     typeName: "Part",
     ids: ["{FNIW4GF1-ANFW-49A4-ANW7-GNWIGHAF4S51FS}"]
   }],
   relationshipDeletes: [{
     typeName: "Buys_part",
     ids: ["{MH4E54G8E-MF4W-1842-2S44-15AF5W8F4S2W8}"]
   }],
   // delete all relationships connected to the deleted entities.
   options:{
     cascadeDelete: true
   }
})
.then((editResult) => {
  console.log("Graph Delete Result", editResult);
});
// Basic example results of adding one entity to the `Supplier` entity type
{
  editResults:[{
    adds:[
    {
      id: "{ANWIFLWF-ANFW-49A4-ANW7-GM51GN5G1878}",
      error: false
    }],
    deletes:[],
    typeName: "Supplier",
    updates:[]
  }],
  hasError: false,
  error: undefined
}

Constructors

GraphApplyEdits

Constructor
new GraphApplyEdits(properties)
Parameter
properties Object
optional

See the properties for a full list of the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
String

The name of the class.

Accessor
Entity[]

A list of entities to add to the knowledge graph.

GraphApplyEdits
GraphNamedObjectDeletes[]

A list of objects containing an entity type and the ids of the entities of that type to delete.

GraphApplyEdits
Entity[]

A list of entities with the modified properties to update in the knowledge graph.

GraphApplyEdits
Object

Additional options to set an input quantization for any geometries being added to the graph and to automatically delete all relationships associated with a deleted entity.

GraphApplyEdits
Relationship[]

A list of relationships to add to the knowledge graph.

GraphApplyEdits
GraphNamedObjectDeletes[]

A list of objects containing a relationship type, and the ids of the relationships of that type to delete.

GraphApplyEdits
Relationship[]

A list of relationships with modified properties to update in the knowledge graph.

GraphApplyEdits

Property Details

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

entityAdds

Property
entityAdds Entity[]

A list of entities to add to the knowledge graph.

Example
//add a new `Supplier` entity
const newEntity = new Entity({
  typeName: "Supplier",
  properties: {
    Name: "Supplier 5",
    EmployeeCount: 681
  }
});

KnowledgeGraphModule.executeApplyEdits(
  graph, {
    entityAdds: [newEntity],
})
.then((editResult) => {
  console.log("Graph Add Result", editResult);
});

entityDeletes

Property
entityDeletes GraphNamedObjectDeletes[]

A list of objects containing an entity type and the ids of the entities of that type to delete. Each object must have thetypeName and ids properties.

Example
entityDeletes: [{
   typeName: "Supplier",
   ids: ["{AMGIE541G-41F1-49A4-8412-CACCC9906E88}", "{HNWIGHE15-WH52-2GE6-1A5W-A1F8W4FS3A1S5}"]
 },{
   typeName: "Part",
   ids: ["{FNIW4GF1-ANFW-49A4-ANW7-GNWIGHAF4S51FS}"]
}]

entityUpdates

Property
entityUpdates Entity[]

A list of entities with the modified properties to update in the knowledge graph.

options

Property
options Object

Additional options to set an input quantization for any geometries being added to the graph and to automatically delete all relationships associated with a deleted entity.

Properties
inputQuantizationParameters InputQuantizationParameters

Custom quantization parameters for input geometry that compresses geometry for transfer to the server. Overrides the default lossless WGS84 quantization.

cascadeDelete Boolean

If true, deleting an entity will automatically delete all relationships connected to that entity. If false, then both the entity and all it's connected relationships must be provided or the executeApplyEdits() operation will fail.

Default Value:false

relationshipAdds

Property
relationshipAdds Relationship[]

A list of relationships to add to the knowledge graph.

Example
//add a new `Supplier` entity
const newRelationship = new Relationship({
  typeName: "buys_part",
  properties: {
    quantity: 18880,
  },
  originId: "{AN4E4G85-41F1-49A4-8412-CACCC9906E88}",
  destinationId: "{9D2D6AFD-41F1-49A4-8412-1DGR8E5D6S1G4}"
});

KnowledgeGraphModule.executeApplyEdits(
  graph, {
    relationshipAdds: [newRelationship],
})
.then((editResult) => {
  console.log("Graph Add Result", editResult);
});

relationshipDeletes

Property
relationshipDeletes GraphNamedObjectDeletes[]

A list of objects containing a relationship type, and the ids of the relationships of that type to delete. Each object in the array must have the typeName and ids properties.

Example
relationshipDeletes: [{
  typeName: "Buys_part",
  ids: ["{MH4E54G8E-MF4W-1842-2S44-15AF5W8F4S2W8}"]
}],

relationshipUpdates

Property
relationshipUpdates Relationship[]

A list of relationships with modified properties to update in the knowledge graph.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor
Boolean

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

Type Definitions

GraphNamedObjectDeletes

Type Definition
GraphNamedObjectDeletes Object

GraphNamedObjectDeletes represents the list of GraphNamedObjects (entities or relationships) of a specific type that will be deleted from a knowledge graph.

Properties
typeName String

The name of the EntityType that the entities belongs to.

ids String[]

A list of the ids of the specified type to delete.

Example
//typical use case
GraphApplyEdits.entityDeletes = [{
   typeName: "Supplier",
   ids: ["{AMGIE541G-41F1-49A4-8412-CACCC9906E88}", "{HNWIGHE15-WH52-2GE6-1A5W-A1F8W4FS3A1S5}"]
 }]

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.