Skip to main content
View as Markdown

Tree fields

Create a tree field and manage its nodes. Tree fields are custom fields whose values form a hierarchy, for taxonomies such as categories, industries or topics. You can assign their values to exhibitors, people, products (items in the API) and sessions (plannings in the API).

Reference: TreeFieldDefinition and TreeFieldNode objects

On this page you can:

How tree fields work​

A tree field is made of nodes, each identified by a path:

  • A selectable node can be assigned to an entity.
  • A non-selectable node is only a grouping label in the hierarchy.
  • Each node has its own translated labels.

A path is a string that joins node identifiers with the |~^ separator. For example, the sub-category SUB-1, under the category CAT-1, under ROOT, has the path ROOT|~^CAT-1|~^SUB-1.

Before you begin​

  • An API key, sent in the Authorization header. The key acts with the roles and permissions of the user who created it. See Authentication.
  • The ID of your event (eventId). See Events.
  • To manage nodes, the ID of the tree field (fieldDefinitionId). See List custom fields.

Create a tree field​

Use the createFieldDefinition mutation with type set to TREE to create a tree field and its initial structure. Describe the structure with two inputs:

  • treeOptions: the list of selectable nodes. Each option has a path: an array of node identifiers, from the root to the target node.
  • treeTranslations: the translated labels of every node in the tree, selectable or not. Each entry has a value (the full node path joined with |~^) and a list of translations, one per language.
Selectable vs. labeled nodes

Not every node needs to be selectable. Intermediate (grouping) nodes can exist in treeTranslations without appearing in treeOptions. However, every node referenced in a path, selectable or not, must have an entry in treeTranslations so it can be displayed with a proper label.

ArgumentDescription
eventIdThe ID of the event on which to create the custom field.
nameThe name of the custom field.
targetThe entity the custom field applies to (PEOPLE, EXHIBITOR, SESSION or ITEM).
typeMust be TREE.
treeOptionsThe paths of the selectable nodes.
treeTranslationsThe labels of every node of the tree, in every language.
Mutation
mutation createFieldDefinition($input: CreateFieldDefinitionV2Input!) {
createFieldDefinition(input: $input) {
event {
id
}
fieldDefinition {
... on TreeFieldDefinition {
id
name
tree {
value
path {
value
translations {
language
value
}
}
}
}
}
errors {
code
message
}
}
}
Variables
{
"input": {
"eventId": "RXZlbnRfMQ==",
"name": "Industry",
"target": "EXHIBITOR",
"type": "TREE",
"isEditable": true,
"isVisible": true,
"translations": [
{ "language": "en_US", "name": "Industry" },
{ "language": "fr_FR", "name": "Secteur d'activité" }
],
"treeOptions": [
{ "path": ["ROOT", "CAT-1"] },
{ "path": ["ROOT", "CAT-1", "SUB-1-1"] },
{ "path": ["ROOT", "CAT-1", "SUB-1-2"] },
{ "path": ["ROOT", "CAT-2"] },
{ "path": ["ROOT", "CAT-2", "SUB-2-1"] }
],
"treeTranslations": [
{
"value": "ROOT",
"translations": [
{ "language": "en_US", "value": "Root" },
{ "language": "fr_FR", "value": "Racine" }
]
},
{
"value": "ROOT|~^CAT-1",
"translations": [
{ "language": "en_US", "value": "Category 1" },
{ "language": "fr_FR", "value": "Catégorie 1" }
]
},
{
"value": "ROOT|~^CAT-1|~^SUB-1-1",
"translations": [
{ "language": "en_US", "value": "Sub Category 1-1" },
{ "language": "fr_FR", "value": "Sous-catégorie 1-1" }
]
},
{
"value": "ROOT|~^CAT-1|~^SUB-1-2",
"translations": [
{ "language": "en_US", "value": "Sub Category 1-2" },
{ "language": "fr_FR", "value": "Sous-catégorie 1-2" }
]
},
{
"value": "ROOT|~^CAT-2",
"translations": [
{ "language": "en_US", "value": "Category 2" },
{ "language": "fr_FR", "value": "Catégorie 2" }
]
},
{
"value": "ROOT|~^CAT-2|~^SUB-2-1",
"translations": [
{ "language": "en_US", "value": "Sub Category 2-1" },
{ "language": "fr_FR", "value": "Sous-catégorie 2-1" }
]
}
]
}
}

Replace the whole tree​

The updateFieldDefinition mutation also works on tree fields: it replaces the whole tree structure (treeOptions and treeTranslations) in a single call. Use it only while no value is assigned yet.

Don't use updateFieldDefinition once values are assigned

Avoid using updateFieldDefinition to change the tree structure of a field whose values are already assigned to entities (exhibitors, people, products or sessions). This mutation overwrites the whole tree and doesn't check existing assignments, which can leave orphaned or inconsistent values.

Once the tree is in use, use the node-level mutations instead:

These mutations validate each change and keep data consistent when you add, rename, move or remove nodes.

Add a node​

Use the createTreeFieldNode mutation to add a node to an existing tree, at a position relative to an existing reference node.

ArgumentDescription
fieldDefinitionIdThe ID of the tree field to add the node to.
targetNodeThe full path of the reference node used for positioning, for example ROOT|~^CAT-1.
positionWhere to place the new node relative to targetNode: ABOVE, BELOW or INSIDE.
nodeIdThe identifier of the new node, for example SUB-NEW. Combined with its parent path, it forms the full path of the new node.
translationsThe translated labels of the new node.
isSelectableWhether the new node can be assigned to entities (it is added to treeOptions) or is only a grouping label.
Mutation
mutation CreateTreeFieldNode($input: CreateTreeFieldNodeInput!) {
createTreeFieldNode(input: $input) {
fieldDefinition {
... on TreeFieldDefinition {
id
tree {
value
path {
value
translations {
language
value
}
}
}
}
}
errors {
code
message
path
}
}
}
Variables
{
"input": {
"fieldDefinitionId": "RmllbGREZWZpbml0aW9uXzY=",
"targetNode": "ROOT|~^CAT-1",
"position": "INSIDE",
"nodeId": "SUB-1-3",
"isSelectable": true,
"translations": [
{ "language": "en_US", "value": "Sub Category 1-3" },
{ "language": "fr_FR", "value": "Sous-catégorie 1-3" }
]
}
}

Update a node​

Use the updateTreeFieldNode mutation to change the translations of a node, whether it is selectable, or both. To move a node, use moveTreeFieldNode instead.

ArgumentDescription
fieldDefinitionIdThe ID of the tree field.
currentNodePathThe full path of the node to update, for example ROOT|~^CAT-1|~^SUB-1-1.
translationsOptional. Replaces all the existing translations of the node.
isSelectableOptional. Sets whether the node can be assigned to entities.
Mutation
mutation UpdateTreeFieldNode($input: UpdateTreeFieldNodeInput!) {
updateTreeFieldNode(input: $input) {
fieldDefinition {
... on TreeFieldDefinition {
id
tree {
value
path {
value
translations {
language
value
}
}
}
}
}
errors {
code
message
path
}
}
}
Variables
{
"input": {
"fieldDefinitionId": "RmllbGREZWZpbml0aW9uXzY=",
"currentNodePath": "ROOT|~^CAT-1",
"isSelectable": true,
"translations": [
{ "language": "en_US", "value": "Category 1 — Updated" },
{ "language": "fr_FR", "value": "Catégorie 1 — Mise à jour" }
]
}
}

Move a node​

Use the moveTreeFieldNode mutation to move a node, and all its descendants, to another position in the tree. Values already assigned to the node or its descendants follow the new path.

ArgumentDescription
fieldDefinitionIdThe ID of the tree field.
currentNodePathThe current full path of the node to move.
targetNodeThe full path of the reference node for the destination.
positionWhere to place the node relative to targetNode: ABOVE, BELOW or INSIDE.
Mutation
mutation MoveTreeFieldNode($input: MoveTreeFieldNodeInput!) {
moveTreeFieldNode(input: $input) {
fieldDefinition {
... on TreeFieldDefinition {
id
tree {
value
path {
value
translations {
language
value
}
}
}
}
}
errors {
code
message
path
}
}
}
Variables
{
"input": {
"fieldDefinitionId": "RmllbGREZWZpbml0aW9uXzY=",
"currentNodePath": "ROOT|~^CAT-2|~^SUB-2-1",
"targetNode": "ROOT|~^CAT-1|~^SUB-1-1",
"position": "ABOVE"
}
}

Delete a node​

Use the deleteTreeFieldNode mutation to delete a node and all its descendants. The response returns the IDs of the deleted FieldValue entities in deletedFieldValueIds, so you can update your own data.

Cascading delete

Deleting a branch node also deletes all its descendants. Any value assigned to the deleted nodes is removed from the related exhibitors, people, products or sessions.

ArgumentDescription
fieldDefinitionIdThe ID of the tree field.
currentNodePathThe full path of the node to delete.
Mutation
mutation DeleteTreeFieldNode($input: DeleteTreeFieldNodeInput!) {
deleteTreeFieldNode(input: $input) {
deletedFieldValueIds
fieldDefinition {
... on TreeFieldDefinition {
id
tree {
value
path {
value
translations {
language
value
}
}
}
}
}
errors {
code
message
path
}
}
}
Variables
{
"input": {
"fieldDefinitionId": "RmllbGREZWZpbml0aW9uXzY=",
"currentNodePath": "ROOT|~^CAT-1"
}
}