Methods like gql() and uql() return a Response containing the raw query results from the database and execution metadata. To use the query results in your application, you need to extract and convert them into a usable data structure.
Response includes the following fields:
Field | Type | Description |
|---|---|---|
aliases | Alias[] | The list of result aliases; each Alias includes fields name and type. |
items | [key: string]: DataItem | An object where each key is an alias name, and each value is the corresponding query result data. |
explainPlan | ExplainPlan | The execution plan. |
status | Status | The status of the execution, including fields code and message. |
statistics | Statistics | Statistics related to the execution, including fields nodeAffected, edgeAffected, totalCost, and engineCost. |
To extract the query results, i.e., the DataItem from Response.items, use the get() or alias() method.
Extracts query results by the alias index.
Parameters
index: number: Index of the alias.Returns
DataItem: The query results.TypeScriptconst response = await driver.gql("MATCH (n)-[e]->() RETURN n, e LIMIT 2"); console.log(response.get(0));
The GQL query returns two aliases (n, e), the get() method gets the DataItem of the alias n at index 0.
OutputDataItem { alias: 'n', type: 2, entities: [ Node { uuid: '6557243256474697731', id: 'U4', schema: 'User', values: [Object] }, Node { uuid: '7926337543195328514', id: 'U2', schema: 'User', values: [Object] } ] }
Extracts query results by the alias name.
Parameters
alias: string: Name of the alias.Returns
DataItem: The query results.TypeScriptconst response = await driver.gql("MATCH (n)-[e]->() RETURN n, e LIMIT 2"); console.log(response.alias("e"));
The GQL query returns two aliases (n, e), the alias() method gets the DataItem of the alias e.
OutputDataItem { alias: 'e', type: 3, entities: [ Edge { uuid: '2', fromUuid: '6557243256474697731', toUuid: '7926337543195328514', from: 'U4', to: 'U2', schema: 'Follows', values: [Object] }, Edge { uuid: '3', fromUuid: '7926337543195328514', toUuid: '17870285520429383683', from: 'U2', to: 'U3', schema: 'Follows', values: [Object] } ] }
You should use a as<DataStructure>() method to convert the DataItem.entities into the corresponding data structure.
If a query returns nodes, you can use asNodes() to convert them into a list of Nodes.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("MATCH (n:User) RETURN n LIMIT 2", requestConfig); const nodes = response.alias("n").asNodes(); for (const node of nodes) { console.log(node) }
OutputNode { uuid: '6557243256474697731', id: 'U4', schema: 'User', values: { name: 'mochaeach' } } Node { uuid: '7926337543195328514', id: 'U2', schema: 'User', values: { name: 'Brainy' } }
If a query returns nodes, you can use asFirstNode() to convert the first returned node into a Node.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("MATCH (n:User) RETURN n", requestConfig); const node = response.alias("n").asFirstNode(); console.log(node)
OutputNode { uuid: '6557243256474697731', id: 'U4', schema: 'User', values: { name: 'mochaeach' } }
If a query returns edges, you can use asEdges() to convert them into a list of Edges.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("MATCH ()-[e]->() RETURN e LIMIT 2", requestConfig); const edges = response.alias("e").asEdges(); for (const edge of edges) { console.log(edge) }
OutputEdge { uuid: '2', fromUuid: '6557243256474697731', toUuid: '7926337543195328514', from: 'U4', to: 'U2', schema: 'Follows', values: { createdOn: '2024-02-10' } } Edge { uuid: '3', fromUuid: '7926337543195328514', toUuid: '17870285520429383683', from: 'U2', to: 'U3', schema: 'Follows', values: { createdOn: '2024-02-01' } }
If a query returns edges, you can use asFirstEdge() to convert the first returned edge into an Edge.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("MATCH ()-[e]->() RETURN e LIMIT 2", requestConfig); const edge = response.alias("e").asFirstEdge(); console.log(edge)
OutputEdge { uuid: '2', fromUuid: '6557243256474697731', toUuid: '7926337543195328514', from: 'U4', to: 'U2', schema: 'Follows', values: { createdOn: '2024-02-10' } }
If a query returns paths, you can use asGraph() to convert them into a Graph.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("MATCH p = ()-[]->() RETURN p LIMIT 2", requestConfig); const graph = response.alias("p").asGraph(); console.log("Unique nodes:", graph.nodes) console.log("Unique edges:", graph.edges) console.log("All paths:", graph.paths)
OutputUnique nodes: Map(3) { '6557243256474697731' => Node { uuid: '6557243256474697731', id: 'U4', schema: 'User', values: { name: 'mochaeach' } }, '7926337543195328514' => Node { uuid: '7926337543195328514', id: 'U2', schema: 'User', values: { name: 'Brainy' } }, '17870285520429383683' => Node { uuid: '17870285520429383683', id: 'U3', schema: 'User', values: { name: 'purplechalk' } } } Unique edges: Map(2) { '2' => Edge { uuid: '2', fromUuid: '6557243256474697731', toUuid: '7926337543195328514', from: 'U4', to: 'U2', schema: 'Follows', values: { createdOn: '2024-02-10' } }, '3' => Edge { uuid: '3', fromUuid: '7926337543195328514', toUuid: '17870285520429383683', from: 'U2', to: 'U3', schema: 'Follows', values: { createdOn: '2024-02-01' } } } All paths: [ Path { nodeUuids: [ '6557243256474697731', '7926337543195328514' ], edgeUuids: [ '2' ], nodes: Map(2) { '6557243256474697731' => [Node], '7926337543195328514' => [Node] }, edges: Map(1) { '2' => [Edge] } }, Path { nodeUuids: [ '7926337543195328514', '17870285520429383683' ], edgeUuids: [ '3' ], nodes: Map(2) { '7926337543195328514' => [Node], '17870285520429383683' => [Node] }, edges: Map(1) { '3' => [Edge] } } ]
If a query retrieves graphs (graphsets) in the database, you can use asGraphSets() to convert them into a list of GraphSets.
TypeScriptconst response = await driver.gql("SHOW GRAPH"); const graphsets = response.get(0).asGraphSets(); for (const graphset of graphsets) { console.log(graphset.name) }
Outputg1 miniCircle amz
If a query retrieves node or edge schemas defined in a graph, you can use asSchemas() to convert them into a list of Schemas.
TypeScriptconst requestConfig: RequestConfig = { graph: "miniCircle" }; const response = await driver.gql("SHOW NODE SCHEMA", requestConfig); const schemas = response.get(0).asSchemas(); for (const schema of schemas) { console.log(schema.name) }
Outputdefault account celebrity country movie
If a query retrieves node or edge properties defined in a graph, you can use asProperties() to convert them into a list of Propertys.
TypeScriptconst requestConfig: RequestConfig = { graph: "miniCircle" }; const response = await driver.gql("SHOW NODE account PROPERTY", requestConfig); const properties = response.get(0).asProperties(); for (const property of properties) { console.log(property.name) }
Output_id gender year industry name
If a query returns results like property values, expressions, or computed values, you can use asAttr() to convert them into an Attr.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("MATCH (n:User) LIMIT 2 RETURN n.name", requestConfig); const attr = response.alias("n.name").asAttr(); console.log(attr)
OutputAttr { propertyType: 7, resultType: 4, values: [ 'mochaeach', 'Brainy' ], name: 'n.name' }
If a query uses the table() function to return a set of rows and columns, you can use asTable() to convert them into a Table.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("MATCH (n:User) LIMIT 2 RETURN table(n._id, n.name) AS result", requestConfig); const table = response.alias("result").asTable(); console.log(table)
OutputTable { name: 'result', headers: [ Header { propertyName: 'n._id', propertyType: 7 }, Header { propertyName: 'n.name', propertyType: 7 } ], rows: [ [ 'U4', 'mochaeach' ], [ 'U2', 'Brainy' ] ] }
If a query retrieves HDC graphs of a graph, you can use asHDCGraphs() to convert them into a list of HDCGraphs.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("SHOW HDC GRAPH", requestConfig); const hdcGraphs = response.get(0).asHDCGraphs(); for (const hdcGraph of hdcGraphs) { console.log(hdcGraph.name); }
Outputg1_hdc_full g1_hdc_nodes
If a query retrieves algorithms installed on an HDC server of the database, you can use asAlgos() to convert them into a list of Algos.
TypeScriptconst response = await driver.gql("SHOW HDC ALGO ON 'hdc-server-1'"); const algos = response.get(0).asAlgos(); for (const algo of algos) { if (algo.type === "algo") { console.log(algo.name); } }
Outputbipartite fastRP
If a query retrieves projections of a graph, you can use asProjections() to convert them into a list of Projections.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("SHOW PROJECTION", requestConfig); const projections = response.get(0).asProjections(); for (const projection of projections) { console.log(projection.name); }
OutputdistG1 distG1_nodes
If a query retrieves node or edge indexes of a graph, you can use asIndexes() to convert them into a list of Indexs.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("SHOW NODE INDEX", requestConfig); const indexes = response.get(0).asIndexes(); for (const index of indexes) { console.log(index) }
OutputIndex { id: '1', name: 'User_name', properties: 'name(1024)', schema: 'User', status: 'DONE', size: undefined, dbType: 0 }
If a query retrieves privileges defined in Ultipa, you can use asPrivileges() to convert them into a list of Privileges.
TypeScriptconst response = await driver.uql("show().privilege()"); const privileges = response.get(0).asPrivileges(); const graphPriviledgeNames = privileges .filter((p) => p.level === PrivilegeLevel.GraphLevel) .map((p) => p.name) .join(", "); console.log("Graph privileges:" + graphPriviledgeNames); const systemPriviledgeNames = privileges .filter((p) => p.level === PrivilegeLevel.SystemLevel) .map((p) => p.name) .join(", "); console.log("System privileges:" + systemPriviledgeNames);
OutputPrivilege { name: 'READ', level: 0 } Privilege { name: 'INSERT', level: 0 } ... Privilege { name: 'DELETE_VECTOR_SERVER', level: 1 }
If a query retrieves policies (roles) defined in the database, you can use asPolicies() to convert them into a list of Policys.
TypeScriptconst response = await driver.gql("SHOW ROLE"); const policies = response.get(0).asPolicies(); for (const policy of policies) { console.log(policy.name); }
Outputmanager Tester operator superADM
If a query retrieves database users, you can use asUsers() to convert them into a list of Users.
TypeScriptconst response = await driver.gql("SHOW USER"); const users = response.get(0).asUsers(); for (const user of users) { console.log(user.username); }
Outputuser01 root johndoe
If a query retrieves processes running in the database, you can use asProcesses() to convert them into a list of Processs.
TypeScriptconst response = await driver.gql("TOP"); const processes = response.get(0).asProcesses(); for (const process of processes) { console.log(process); }
OutputProcess { processId: '1060719', processQuery: 'MATCH p = ()-{1,7}() RETURN p', duration: '1', status: 'RUNNING' }
If a query retrieves jobs of a graph, you can use asJobs() to convert them into a list of Jobs.
TypeScriptconst requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("SHOW JOB", requestConfig); const jobs = response.get(0).asJobs(); for (const job of jobs) { console.log(job); }
OutputJob { id: '5', graphName: 'g1', query: 'CREATE INDEX User_name ON NODE User (name)', type: 'CREATE_INDEX', errMsg: '', result: null, startTime: '2025-09-23 17:43:54', endTime: '2025-09-23 17:43:55', status: 'FINISHED', progress: '' } Job { id: '5_1', graphName: 'g1', query: '', type: 'CREATE_INDEX', errMsg: '', result: null, startTime: '2025-09-23 17:43:55', endTime: '2025-09-23 17:43:55', status: 'FINISHED', progress: '' } Job { id: '5_2', graphName: 'g1', query: '', type: 'CREATE_INDEX', errMsg: '', result: null, startTime: '2025-09-23 17:43:55', endTime: '2025-09-23 17:43:55', status: 'FINISHED', progress: '' } Job { id: '5_3', graphName: 'g1', query: '', type: 'CREATE_INDEX', errMsg: '', result: null, startTime: '2025-09-23 17:43:55', endTime: '2025-09-23 17:43:55', status: 'FINISHED', progress: '' } Job { id: '1', graphName: 'g1', query: 'CREATE HDC GRAPH g1_hdc_full ON "hdc-server-1" OPTIONS {\n' + ' nodes: {"*": ["*"]},\n' + ' edges: {"*": ["*"]},\n' + ' direction: "undirected",\n' + ' load_id: true,\n' + ' update: "static"\n' + '}', type: 'CREATE_HDC_GRAPH', errMsg: '', result: Map(4) { 'edge_count' => 4, 'edge_schema' => { Follows: [Object], default: [Object] }, 'node_count' => 5, 'node_schema' => { User: [Object], default: [Object] } }, startTime: '2025-09-23 17:29:05', endTime: '2025-09-23 17:29:07', status: 'FINISHED', progress: '' } Job { id: '1_1', graphName: 'g1', query: '', type: 'CREATE_HDC_GRAPH', errMsg: '', result: null, startTime: '2025-09-23 17:29:05', endTime: '2025-09-23 17:29:07', status: 'FINISHED', progress: '' }
TypeScriptimport { UltipaDriver } from "@ultipa-graph/ultipa-driver"; import type { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types/index.js"; import { RequestConfig } from "@ultipa-graph/ultipa-driver/dist/types/types.js"; let sdkUsage = async () => { const ultipaConfig: ULTIPA.UltipaConfig = { // URI example: hosts: ["xxxx.us-east-1.cloud.ultipa.com:60010"] hosts: ["10.xx.xx.xx:60010"], username: "<username>", password: "<password>" }; const driver = new UltipaDriver(ultipaConfig); const requestConfig: RequestConfig = { graph: "g1" }; const response = await driver.gql("MATCH (n:User) RETURN n LIMIT 2", requestConfig); const nodes = response.alias("n").asNodes(); for (const node of nodes) { console.log(node) }; }; sdkUsage().catch(console.error);