GraphQL’s a powerful tool for querying data, but when you’re dealing with highly connected, graph-like data, it can feel like you’re trying to untangle a ball of yarn with oven mitts on. That’s where Vector’s GraphQL API comes in, offering a way to manage and query your network topology that feels more like a scalpel than a blunt instrument.
Imagine you’ve got a network, and you want to know all the active routes between Router A and Router B, but only if those routes traverse a specific interface on Router C. A traditional REST API might require multiple calls: one to get Router A’s details, another for Router B, then a third to find Router C’s interfaces, and you’d stitch it all together in your application. With Vector GraphQL, you can ask for exactly that in a single query.
Here’s a glimpse of what that query might look like. Let’s say we’re querying for devices and their immediate neighbors:
query {
devices {
name
ipAddress
neighbors {
device {
name
ipAddress
}
interface
}
}
}
This query asks for all devices, and for each device, it wants its name, IP address, and then a list of its neighbors. For each neighbor, it wants the neighbor’s device name, IP address, and the specific interface on the current device that connects to that neighbor. This is already a step up from stitching together multiple REST endpoints.
But the real power emerges when you start chaining these relationships to traverse the topology. Let’s say you want to find all devices reachable from "Router-1" within two hops, excluding any devices that are part of a "management" VRF.
query FindNearbyDevices($startDevice: String!, $maxHops: Int!) {
device(name: $startDevice) {
reachableDevices(maxHops: $maxHops, excludeVrf: "management") {
device {
name
ipAddress
}
hopCount
}
}
}
You’d execute this with variables like:
{
"startDevice": "Router-1",
"maxHops": 2
}
This query starts at "Router-1", asks for devices reachable within 2 hops, and specifically filters out any devices associated with the "management" VRF. The result will give you a list of devices, their IP addresses, and how many hops away they are from "Router-1".
Internally, Vector’s GraphQL API builds upon a robust graph database model. When you ingest your network data (e.g., from device APIs, configuration files, or existing monitoring systems), Vector constructs a graph where devices are nodes and connections (physical links, L2 adjacencies, L3 peering) are edges. The GraphQL schema is designed to mirror this graph structure, allowing for declarative queries that traverse these nodes and edges.
The key levers you control are the types of data you ingest and how you model your relationships. Vector supports various data sources, and the way you map device attributes (like hostname, ip_address, vendor) and connection details (like interface_name, vlan, neighbor_ip) into its internal graph model directly impacts the queries you can perform. For instance, if you ingest BGP peering information, you can query for BGP neighbors. If you ingest LLDP data, you can query for L2 neighbors.
The most surprising thing about how Vector’s GraphQL API handles complex topology queries is its ability to perform transitive queries efficiently without materializing the entire path for every step. When you ask for reachableDevices(maxHops: 3), it doesn’t necessarily compute all paths of length 1, then all paths of length 2 from those, and so on, in a naive way. Instead, it leverages graph traversal algorithms optimized for finding nodes within a certain distance, pruning branches that don’t meet criteria early. This is why you can ask for 5 hops and get a result in seconds, not minutes or hours.
Once you’re comfortable querying your existing topology, the next logical step is to start using the API to modify your topology data, perhaps by adding or updating device information or link states.