Associating a BinBar with a Container Site
BinBars and container sites have a relationship which allows data from a BinBar such as weight measurements to be assocated with a particlar container.
Just like in the field, the relationship between a container a a BinBar can change. For example, a container on a BinBar can be swapped out for a different one.
In order keep track of data such as making sure weight data reflects the correct container site, it is important that real world changes are reflected in the database.
An exaxmple of this is if a BinBar is moved from one factory to another. If this happens, the BinBar would need to be detached from the old container site and attached to the new one
This relationship can be updated with the updateContainerSiteBinBar mutation.
updateContainerSiteBinBar's functionality depends on the current relationship between the BinBar and the container site. Because of this, it may be useful to query for the current status of the relationship before making changes
updateContainerSiteBinBar is able to to perform three different operations depending on input and current status of the relationship. To learn more, visit the updateContainerSiteBinBar documentation
updateContainerSiteBinBar can:
- Connect a BinBar to a container site that does not have a BinBar
- Replace a BinBar that is connected to a container site with a new BinBar
- Remove a BinBar from a container site
mutation UpdateContainerSiteBinBar($id: ID!, $binBarID: ID) {
updateContainerSiteBinBar(id: $id, binBarID: $binBarID) {
id
# Some `ContainerSite` fields omitted for brevity including the container site's BinBar
}
}
variables = { id: containerSiteID, binBarID: BinBarID }
Notice that the queries for updateContainerSiteBinBar look identical when replacing and connecting a BinBar. This is because the prior relationship has an affect on what updateContainerSiteBinBar does.
mutation UpdateContainerSiteBinBar($id: ID!, $binBarID: ID) {
updateContainerSiteBinBar(id: $id, binBarID: $binBarID) {
id
# Some `ContainerSite` fields omitted for brevity including the container site's BinBar
}
}
variables = { id: containerSiteID, binBarID: newBinBarID }
When a BinBar is replaced, the old BinBar will still remain in your account and have the same ID, but it will no longer be linked to a container site. A container site can only have no BinBar or one BinBar. A BinBar can only be assigned to one container site at a time.
mutation UpdateContainerSiteBinBar($id: ID!, $binBarID: ID) {
updateContainerSiteBinBar(id: $id, binBarID: $binBarID) {
id
# Some `ContainerSite` fields omitted for brevity including the container site's BinBar
}
}
variables = { id: containerSiteID, binBarID: '' };
Removing a BinBar requires an input of only a container site ID