Link Existing Objects
The link
option allows you to link existing objects to a “parent” object.
In the “parent” input object (whether in a createObject
or updateObject
mutation) where the object has relationships defined to other objects, a relationships field should be available. This object will include a link
argument which defines a list of either UIDs or external IDs (or a mix of both) of objects to create relationships.
The body of the link field can be either a single string or an array of strings to link multiple objects.
Example 1: Linking a single object
mutation updateSeason {
updateSeason(uid: "<season UID>", season: {
relationships: {
episodes: {
link: "<episode UID>"
}
}
}
)
{
uid
episodes {
uid
}
}
}
Example 2: Linking multiple objects
mutation updateSeason {
updateSeason(uid: "<season UID>", season: {
relationships: {
episodes: {
link: ["<episode UID>", "<another episode UID>"]
}
}
}
)
{
uid
episodes {
uid
}
}
}
Example 3: Linking with external ID
mutation updateSeason {
updateSeason(uid: "<season UID>", season: {
relationships: {
episodes: {
link: ["<episode External ID>", "<another episode UID>"]
}
}
}
)
{
uid
episodes {
uid
}
}
}
Updated 7 months ago