ArcGIS Arcade can be used to query ArcGIS Knowledge Graphs directly from custom pop-ups in web maps, map apps, link charts, ArcGIS Pro, ArcGIS AllSource, ArcGIS Knowledge Studio, and Map Viewer. This lets analysts enrich a selected feature, entity, or relationship with connected context from an enterprise knowledge graph—without moving users out of their existing map or link-chart workflow.
This pattern is useful when a feature layer contains only part of the operational picture, but the broader context lives in a knowledge graph. A pop-up can match the selected feature to a graph entity by unique ID, use the selected feature’s geometry in a spatial graph query, summarize connected entities, or generate a URL that opens the related entity in Knowledge Studio.
In this context, “side-loading context” means retrieving related graph information at click time and displaying it in a pop-up, rather than copying graph-derived attributes into the feature layer.
There are two common patterns: first, feature-layer pop-ups can use a shared ID, attribute, or geometry to find related entities in a knowledge graph; second, knowledge graph layer pop-ups can start from the selected entity or relationship and query additional connected context from the same graph.
Use this pattern when your map layer shows the operational feature, but related context lives in an ArcGIS Knowledge Graph. Common examples include finding suppliers, assets, facilities, parcels, customers, documents, or other connected entities related to a selected feature.
Let’s walk through an example. Suppose you have a feature layer showing a hurricane prediction cone overlaid on a map of key supplier facilities. In addition, you maintain more detailed information about your suppliers—and their suppliers—within a separate knowledge graph in ArcGIS. Now, when you click on a weather-related feature, your pop-up can instantly run a spatial query against your knowledge graph. This allows you to identify not only all your tier 1 suppliers located within the affected area, but also their upstream suppliers and any parts that may need to be pre-positioned (shipped earlier) in preparation for the hurricane.
You can also configure your pop-up to run multiple queries at once. For example, the same pop-up could display a summary of all downstream products, key customers, and expected revenue that might be impacted in the next 30 days if that supplier’s facility is disrupted by the hurricane.
Custom pop-ups can also generate Knowledge Studio URLs that open the selected feature, matched graph entity, or related entity for deeper exploration.
Starting with ArcGIS Enterprise 11.3 and ArcGIS Pro 3.3, Arcade expressions can query ArcGIS Knowledge Graphs from custom pop-ups in maps and link charts. These pop-ups can be configured for feature layers or knowledge graph layers in ArcGIS Pro, ArcGIS AllSource, ArcGIS Knowledge Studio, Map Viewer, and web map applications.
The pop-up uses Arcade graph functions to send information from the selected feature, entity, or relationship into a graph query. The query can return connected entities, relationship details, calculated summaries, spatial matches, or formatted output that appears directly in the pop-up.
For feature-layer pop-ups, the selected feature is typically matched to a knowledge graph entity using a shared GUID, asset ID, facility ID, parcel ID, or other unique attribute. The pop-up can also pass the selected feature’s geometry into a spatial graph query to find graph entities that intersect, fall within, or relate to that area.
For knowledge graph layer pop-ups, the selected entity or relationship is already the starting point. Arcade can use that selection to query additional graph context, summarize connected data, or generate a Knowledge Studio URL that opens the related entity for deeper exploration.
Most Arcade-based Knowledge Graph pop-ups follow the same basic pattern: identify the graph, define the selected feature or entity as the input, run a graph query, format the results, and return a pop-up-ready dictionary. Let's walk through each step.
In Arcade, “connecting” to a knowledge graph means identifying the graph you want to query. Use KnowledgeGraphByPortalItem() to reference a graph by portal item. If the pop-up is built on a Knowledge Graph Layer and queries the same graph, you can skip this step and use $graph directly in the query.
Example code: reference the knowledge graph
// Option A: query a target graph by portal item
var portalUrl = "https://[YOUR_ORG_PORTAL_URL]/portal";
var graphItemId = "[KNOWLEDGE_GRAPH_ITEM_ID]";
var kg = KnowledgeGraphByPortalItem(Portal(portalUrl), graphItemId);
// Option B: query the same graph as the selected graph layer
var kg = $graph;
Next, decide what the pop-up will pass into the graph query: a feature attribute, the selected feature’s geometry, or the selected graph entity or relationship.
For feature-layer pop-ups, this usually means:
Query Patterns | Description | Example Use Cases |
Match by a Unique ID | Match a selected feature to a graph entity using a shared ID such as a GUID, asset ID, facility ID, or parcel ID.
| · Fetch connected entities and properties · Aggregate statistics about groups of connected entities · Aggregate statistics about properties of those connected entities · Find employees matching open roles, proximity, and skill criteria. |
Match by Intersecting Shape | Use the selected feature’s geometry as an input to a spatial graph query that returns entities intersecting, contained within, or related to that shape.
| · Find downstream suppliers of suppliers within a selected polygon. · Aggregate statistics from properties on connected entities or relationships |
Example code: capture the selected input
// Attribute-based input from a selected feature
var selectedId = $feature.[SHARED_ID_FIELD];
var params = { id: selectedId };
// Graph-layer input from a selected entity
var selectedGuid = $feature.globalid;For graph-layer pop-ups, the selected entity is already the starting point, so the expression can typically use that entity’s GUID directly.
Graph queries can also use the selected feature’s geometry to filter results spatially, as in the supply chain example described above.
// Geometry-based input from a selected feature
var selectedGeom = Generalize($feature, 5000, true, 'meters');
var spatialParams = { feature_geom: selectedGeom };querygraph(kg, "MATCH (s:Supplier) WHERE esri.graph.ST_Contains($feature_geom, s.shape) RETURN s.Name, s.globalid", {'feature_geom': $feature}
This step anchors the query to the feature, entity, relationship, or geometry the user selected.
Define the insight the pop-up should return. Common query operations include:
The goal is to turn connected graph data into a concise answer the user can understand at a glance.
Example code: run relationship and spatial graph queries
var results = querygraph(
kg,
"MATCH (start:EntityType {globalid: $id})-[:RELATIONSHIP_TYPE]->(related:EntityType) RETURN related.Name, related.globalid LIMIT 10",
{ id: selectedGuid }
);
var spatialResults = querygraph(
kg,
"MATCH (e:EntityType) WHERE esri.graph.ST_Contains($feature_geom, e.shape) RETURN e.Name, e.globalid",
{ feature_geom: selectedGeom }
);After the query returns results, format them for the pop-up. Most expressions:
This is where raw graph results become readable context for the selected map feature, entity, or link-chart element.
Example code: format graph results for display
var finalText = "";
for (var r in results) {
var name = results[r][0];
var guid = results[r][1];
finalText += "<b>" + name + "</b><br>";
}
if (IsEmpty(finalText)) {
finalText = "No related graph results found.";
}Finally, return the dictionary. ArcGIS reads the returned object and renders the formatted text, sections, tables, links, or controls in the pop-up.
Example code: return the pop-up content
return {
type: 'text',
text: finalText
};Arcade expressions can format graph query results in several pop-up-friendly ways. Common patterns include:
See example: Arcade_Graph_Pop-ups.mp4
In this simple example, the graph query within the Arcade expression returns the Suppliers located within the polygon of a selected weather feature. The script also uses the Arcade geometry function - generalize - to simplify the shape of the selected polygon to improve performance of the spatial openCypher query.
This is an example of a query you could use in a Map with an independent Feature Service there for reference alongside a spatial Knowledge Graph layer, or the graph could not be present in the map at all!
//The portal item ID of the Knowledge Graph service (pid) and server url portal url (Change these)
var pid = "d03d80ca35c94cadb963f845acbd0de1"
var portal_url = " https://[YOUR_ORG_PORTAL_URL].com/portal/"
var kg = KnowledgeGraphByPortalItem(Portal(portal_url), pid)
// To simplify the polygon for better performance, we are using the Generalize function
var gen = Generalize($feature, 5000, true, 'meters')
var results = querygraph(kg, "MATCH (s:Supplier) WHERE esri.graph.ST_Contains($feature_geom, s.shape) RETURN s.Name, s.globalid", {'feature_geom': gen});
var final_str = "";
var cnt = 0
for (var r in results) {
var name = results[r][0]
var g_id = StandardizeGuid(results[r][1],'digits-hyphen')
var studio_url = '<a href = ' + server_url + '/apps/knowledge-studio/main?id=' + pid + '&selectedContentId=dataExplorer&selectedContentElement=%7B' + g_id + '%7D&selectedContentInstruction=entity>'
final_str = final_str + studio_url + " " + name + "</a><br>"
}
return {
type : 'text',
text : final_str
}
I plan follow this blog with some additional full sample queries, along with AI prompts to help you leverage LLMs to help you build your own Arcade + Graph queries. You can also go deeper by reviewing the Arcade Knowledge Graph function documentation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.