Manage Relationships

Relationships between objects can be created or deleted with the editRelationshipConfiguration mutation.

The arguments for editing relationships are:

ArgumentDescription
operationThe type of edit to make (e.g CREATE or UPDATE).
from_classThe name of the object class to make the relationship from
to_classThe name of the object class to make the relationship to
relationship_nameName of the forward relationship from the from_class object to the to_class object
reverse_relationship_nameThe name of the opposite relationship from the to_class to the from_class

📘

All fields are required, for both create and delete operations!

When a new relationship is created it is always a many-to-many relationship, and the relationship will appear in both objects.

Create New Relationship

This example shows creating a new relationship between 2 objects.

mutation CreateRelationship {
  editRelationshipConfiguration(
    relationships: {
      from_class: Person
      operation: CREATE
      relationship_name: "genres"
      reverse_relationship_name: "people"
      to_class: Genre
    }
  ) {
    version
    messages
  }
}

Remove Existing Relationship

This example shows removing an existing relationship between Episode and Season.

📘

When a relationship is removed, the data still remains in the database. So if you delete a relationship, activate the version, then decide you want to rollback, all the relationships between objects would continue to work as they did before the deletion.

mutation RemoveRelationship {
  editRelationshipConfiguration(
    relationships: {
      from_class: Episode
      operation: DELETE
      relationship_name: "seasons"
      reverse_relationship_name: "episodes"
      to_class: Season
    }
  ) {
    version
    messages
  }
}