Manage Relationships
Relationships between objects can be created or deleted with the editRelationshipConfiguration
mutation.
The arguments for editing relationships are:
operation
: The type of edit to make (e.gCREATE
orUPDATE
).from_class
: The name of the object class to make the relationship fromto_class
: The name of the object class to make the relationship torelationship_name
: Name of the forward relationship from thefrom_class
object to theto_class
objectreverse_relationship_name
: The name of the opposite relationship from theto_class
to thefrom_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 MyMutation {
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 MyMutation {
editRelationshipConfiguration(
relationships: {
from_class: "Episode"
operation: DELETE
relationship_name: "seasons"
reverse_relationship_name: "episodes"
to_class: "Season"
}
) {
version
messages
}
}
Updated 4 months ago