Skip to main content

Working with groups

Groups are first-class objects in Infrahub that can be queried and manipulated through GraphQL. Groups provide powerful ways to organize and operate on collections of infrastructure objects.

Querying groups and their members​

Query a specific group and its members:

query {
CoreStandardGroup(name__value: "ProductionRouters") {
edges {
node {
name {
value
}
members {
edges {
node {
display_label
__typename
}
}
}
}
}
}
}

Finding groups for an object​

Every object automatically gains relationships to find its group memberships:

query {
InfraDevice(name__value: "router01") {
edges {
node {
name {
value
}
member_of_groups {
edges {
node {
name {
value
}
}
}
}
}
}
}
}

Query groups for bulk operations​

Groups enable efficient bulk queries across related objects:

query {
CoreStandardGroup(name__value: "EdgeDevices") {
edges {
node {
members {
edges {
node {
... on InfraDevice {
interfaces {
edges {
node {
name {
value
}
ip_addresses {
edges {
node {
address {
value
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

This pattern enables powerful operations where you can process all objects in a group with a single query, making groups essential for scalable infrastructure management.

See organizing objects with groups for creating and managing groups, and understanding groups for architectural concepts.