Skip to content

graphql_string

Collection Note

This module is part of the networktocode.nautobot collection. To install the collection, use:

ansible-galaxy collection install networktocode.nautobot

Synopsis

  • The filter converts a dictionary to a GraphQL string.

Parameters

Parameter Data Type Environment Variable Comments
query
required
dict A dictionary mapping to the GraphQL call to be made.
start int The starting indentation when compiling the string.

Examples

# Code:
- set_fact:
    gql_query: "{{ gql_dict | networktocode.nautobot.graphql_string }}"
  vars:
    gql_dict:
      query:
        devices:
          name:
          primary_ip4:
            host:
          platform:
            napalm_driver:

# Output:
# ok: [localhost] => {
#     "ansible_facts": {
#         "gql_query": "query {\n  devices {\n    name\n    primary_ip4 {\n      host\n    }\n    platform {\n      napalm_driver\n    }\n  }\n}"
#     },
#     "changed": false
# }

Return Values

Key Data Type Description Returned
graphql_string str GraphQL query string always

Authors

  • Mikhail Yohman (@fragmentedpacket)