Skip to main content

Relationship mutations

Create Relationship

mutation CreateRelationship (
$relationshipKey: String!
$relationshipType: String!
$relationshipClass: String!
$fromEntityId: String!
$toEntityId: String!
$timestamp: Long
$properties: JSON
) {
createRelationship (
relationshipKey: $relationshipKey,
relationshipType: $relationshipType,
relationshipClass: $relationshipClass,
fromEntityId: $fromEntityId,
toEntityId: $toEntityId,
timestamp: $timestamp,
properties: $properties
) {
relationship {
_id
...
}
edge {
id
toVertexId
fromVertexId
relationship {
_id
...
}
properties
}
}
}

Variables:

{
"relationshipKey": "<a relationship key>",
"relationshipType": "<a relationship type>",
"relationshipClass": "<a relationship class>",
"fromEntityId": "<the _id of the from entity>",
"toEntityId": "<the _id of the to entity>",
"timestamp": 1529329792552,
"properties": {
// Custom properties on the relationship
...
}
}

Update Relationship

mutation UpdateRelationship (
$relationshipId: String!
$timestamp: Long
$properties: JSON
) {
updateRelationship (
relationshipId: $relationshipId,
timestamp: $timestamp,
properties: $properties
) {
relationship {
_id
...
}
edge {
id
toVertexId
fromVertexId
relationship {
_id
...
}
properties
}
}
}

Variables:

{
"relationshipId": "<a relationship Id (relationship._id)>",
"timestamp": 1529329792552,
"properties": {
// Custom properties to get updated
...
}
}

Delete Relationship

mutation DeleteRelationship (
$relationshipId: String!
$timestamp: Long
$hardDelete: Boolean
) {
deleteRelationship (
relationshipId: $relationshipId,
timestamp: $timestamp,
hardDelete: $hardDelete,
) {
relationship {
_id
...
}
edge {
id,
toVertexId,
fromVertexID
relationship {
_id
...
}
properties
}
}
}

Variables:

{
"entityId": "<an entity Id (entity._id)>",
"timestamp": 1529329792552,
"hardDelete": true
}
caution

hardDelete is a flag that completely removes all information related to the relationship in a way that is not recoverable.