Using connect on a 1:* relationship question


#1

Looking to verify the behavior I am seeing.

If you have an existing “Parent” w\ a known ID.

Then create a child and specify the parentID as a connect arg

//datamodel
type Item {
id: ID! @unique @id
parent: Parent @relation(name: “ItemOnParent”)
}

type Parent {
id: ID! @unique @id
item: [Item] @relation(name: “ParentOnItems”)
}

//vars
variables = {
“data”: {
“Parent”: {
“connect”: {
“id”: parentId
}
}
}
}

What I’m seeing is the child has the appropriate parent ID listed. However, the parent relationship is not updated.

Is this the intended behavior?

If so what is the appropriate method for updating the parent reference?


#2

Ah nm. I didnt declare both sides of the relation with the same name.

type Item {
id: ID! @unique @id
parent: Parent @relation(name: “Relation1”)
}

type Parent {
id: ID! @unique @id
item: [Item] @relation(name: “Relation1”)
}