Back to all configurations
External Data Resolver

External Data Resolver

Declare External Data Resolvers that fetch values from your own API at query time, one with GET and one with POST, using the indykite_external_data_resolver resource.

External Data Resolver

An External Data Resolver lets a ContX IQ query read a value that lives outside the graph: a node property whose external_value names the resolver is filled at query time by calling your API.

This Terraform configuration creates two resolvers:

1. A GET resolver whose URL carries a placeholder ($customer_id) filled from the query's input parameters, with an Authorization header.

2. A POST resolver whose request_payload is a JSON body template, with the Content-Type header set.

Both select the value to return from the JSON answer with response_selector. The bearer token comes from a sensitive variable.

Use case

Scenario: a customer's service tier is maintained in the company's own CRM API and must not be copied into the graph.

- A Customer node is captured with a tier property whose external_value is the resolver's name.

- When a Knowledge Query reads that property, the platform calls the resolver with the input parameters, applies response_selector and returns the live value in the query result.

- Changing the API's URL, headers or selector is an apply; the graph data stays untouched.

Requirements

- ServiceAccount credentials created in the IndyKite Hub for your organization.

- IndyKite Terraform provider 0.49.0 or later, the release the example pins in required_providers; the Terraform guide lists the version each feature first appeared in.

- A project GID for project_id.

- An HTTPS endpoint of your own that answers JSON, reachable from the public internet; a URL whose host is a literal private or loopback address is refused when the configuration is saved.

Steps

1. Put your project GID in project_id, your API's URL in url and the JSON path of the value in response_selector.

2. Provide the bearer token through the customer_api_token variable and apply.

3. Capture a node with a property whose external_value is the resolver's name, as the External Data Resolver guide shows.

4. Execute a Knowledge Query that reads that property; the resolver is called and its value returned.

Two External Data Resolvers, GET and POST, with a placeholder in the URL and in the payload.

main.tf

terraform {
  required_providers {
    indykite = {
      source  = "indykite/indykite"
      version = ">= 0.49.0" # or a later release
    }
  }
}

# indykite provider integrates IndyKite platform with Terraform scripting.
# Provider for now does not support any parameters and all is set within service account credential file.
provider "indykite" {}

# An External Data Resolver fetches a value from your own API when a ContX IQ
# query reads a property whose external_value names the resolver. The URL and
# the payload may carry placeholders ($name) filled from the query's input
# parameters; response_selector picks the value out of the JSON answer.
resource "indykite_external_data_resolver" "customer_api_get" {
  name         = "terraform-resolver-get"
  display_name = "Customer API (GET)"
  description  = "Reads a customer record from the company API"
  project_id   = "gid:AAAAAmluZHlraURlgAABDwAAAAA" # your project GID

  url    = "https://api.example.com/customers/$customer_id"
  method = "GET"
  headers {
    name   = "Authorization"
    values = ["Bearer ${var.customer_api_token}"]
  }
  request_type      = "json"
  response_type     = "json"
  response_selector = ".customer.tier"
}

# A POST resolver sends a JSON body; request_payload is the body template.
resource "indykite_external_data_resolver" "customer_api_post" {
  name         = "terraform-resolver-post"
  display_name = "Customer API (POST)"
  description  = "Looks a customer up by email"
  project_id   = "gid:AAAAAmluZHlraURlgAABDwAAAAA" # your project GID

  url    = "https://api.example.com/customers/search"
  method = "POST"
  headers {
    name   = "Authorization"
    values = ["Bearer ${var.customer_api_token}"]
  }
  headers {
    name   = "Content-Type"
    values = ["application/json"]
  }
  request_type      = "json"
  request_payload   = "{\"email\": \"$email\"}"
  response_type     = "json"
  response_selector = ".results[0].tier"
}

# The bearer token the resolvers send to your API, kept out of the module.
variable "customer_api_token" {
  type      = string
  sensitive = true
}