updated GraphQL for Netbox 4.4

This commit is contained in:
Johannes Erwerle 2025-10-16 13:35:43 +02:00
parent d25f7aeec3
commit 23fb524f0a
2 changed files with 11 additions and 4 deletions

View file

@ -21,6 +21,9 @@ from pynetbox_config_helper import build_argparser, resolve_graphql_config
import importlib.resources
class GraphQlError(Exception):
pass
logger = logging.getLogger(__name__)
@ -72,6 +75,10 @@ def graphql_query(client: GraphqlClient, query, variables: Optional[Dict] = None
data = client.execute(query, variables=variables)
errors = data.get("errors")
if errors:
raise GraphQlError(errors)
logger.debug(f"received data from GraphQL:\n{pformat(data)}")
return data
@ -161,8 +168,8 @@ def build_vm():
query,
variables={
"address": str(interface_addr.ip),
"prefix_length": str(interface_addr.network.prefixlen),
"vrf": "null",
"prefix_length": "/" + str(interface_addr.network.prefixlen),
"vrf": None,
},
)["data"]