diff --git a/package-lock.json b/package-lock.json index 94979644..d824a292 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,9 +13,9 @@ "@msgpack/msgpack": "^3.1.1", "@tanstack/react-query": "^5.80.3", "@tanstack/react-table": "^8.21.3", - "@trustgraph/client": "^1.3.1", + "@trustgraph/client": "^1.4.0", "@trustgraph/react-provider": "^1.3.0", - "@trustgraph/react-state": "^1.3.1", + "@trustgraph/react-state": "^1.4.0", "@types/dagre": "^0.7.53", "compute-cosine-similarity": "^1.1.0", "dagre": "^0.8.5", @@ -2573,9 +2573,9 @@ } }, "node_modules/@trustgraph/client": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@trustgraph/client/-/client-1.3.1.tgz", - "integrity": "sha512-2tVMdixjlVQt6/vy7HRS5+LxOv8MUH03yDJrrJ9tbglw+UMyueXncFOIogTyIPk+jxxmL1XADtASKumUkix1OQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@trustgraph/client/-/client-1.4.0.tgz", + "integrity": "sha512-qz4dlI61LQISNfQib8JymNu/sM4wQymtkidEOVybhSXcD39ZDETj4VI/BN41qjiMegKC1WJxKFYDFo6D9au/yQ==", "license": "Apache-2.0" }, "node_modules/@trustgraph/react-provider": { @@ -2589,9 +2589,9 @@ } }, "node_modules/@trustgraph/react-state": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@trustgraph/react-state/-/react-state-1.3.1.tgz", - "integrity": "sha512-OsK8+fevcYwRTzpvLVVORXe/m9drb8bkUoiGnhqi9t2zRB0P2npIO1CkS/x/eQj0llQAMQQbJ5hjenUMH1Z0+g==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@trustgraph/react-state/-/react-state-1.4.0.tgz", + "integrity": "sha512-WFenhkzQBXViCQAdMQSQjOt+dJYRgKOEwXQ6SstUVfq2a/ZU//GB7juhLKXa5yaE1ymRIin66+XbSOwbzAHBfA==", "license": "MIT", "dependencies": { "@trustgraph/client": "^1.3.0", diff --git a/package.json b/package.json index 91d832a8..9e9b0faf 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,9 @@ "@msgpack/msgpack": "^3.1.1", "@tanstack/react-query": "^5.80.3", "@tanstack/react-table": "^8.21.3", - "@trustgraph/client": "^1.3.1", + "@trustgraph/client": "^1.4.0", "@trustgraph/react-provider": "^1.3.0", - "@trustgraph/react-state": "^1.3.1", + "@trustgraph/react-state": "^1.4.0", "@types/dagre": "^0.7.53", "compute-cosine-similarity": "^1.1.0", "dagre": "^0.8.5", diff --git a/src/components/structured-query/RunGraphQLTab.tsx b/src/components/structured-query/RunGraphQLTab.tsx index 537397aa..ad4266ca 100644 --- a/src/components/structured-query/RunGraphQLTab.tsx +++ b/src/components/structured-query/RunGraphQLTab.tsx @@ -1,7 +1,7 @@ import React, { useState, useMemo } from "react"; import { VStack, HStack, Button, Textarea, Text, Box } from "@chakra-ui/react"; import { Play } from "lucide-react"; -import { useObjectsQuery } from "@trustgraph/react-state"; +import { useRowsQuery } from "@trustgraph/react-state"; import { createColumnHelper, useReactTable, @@ -17,12 +17,12 @@ const columnHelper = createColumnHelper(); const RunGraphQLTab: React.FC = () => { const [query, setQuery] = useState(""); - const objectsQuery = useObjectsQuery(); + const rowsQuery = useRowsQuery(); const handleSubmit = () => { if (!query.trim()) return; - objectsQuery.executeQuery({ query: query.trim() }); + rowsQuery.executeQuery({ query: query.trim() }); }; const handleKeyPress = (e: React.KeyboardEvent) => { @@ -34,20 +34,20 @@ const RunGraphQLTab: React.FC = () => { // Dynamically create columns based on the first row of results const { columns, tableData } = useMemo(() => { - if (!objectsQuery.data?.data) { + if (!rowsQuery.data?.data) { return { columns: [], tableData: [] }; } // Extract the first array of results from the GraphQL response // GraphQL responses typically have structure like { data: { users: [...] } } - const dataKeys = Object.keys(objectsQuery.data.data); + const dataKeys = Object.keys(rowsQuery.data.data); if (dataKeys.length === 0) { return { columns: [], tableData: [] }; } // Get the first data collection const firstKey = dataKeys[0]; - const results = objectsQuery.data.data[firstKey]; + const results = rowsQuery.data.data[firstKey]; if (!Array.isArray(results) || results.length === 0) { return { columns: [], tableData: [] }; @@ -91,7 +91,7 @@ const RunGraphQLTab: React.FC = () => { columns: resultColumns, tableData: results as GraphQLResultRow[], }; - }, [objectsQuery.data]); + }, [rowsQuery.data]); // Create the table instance const table = useReactTable({ @@ -136,8 +136,8 @@ const RunGraphQLTab: React.FC = () => { onClick={handleSubmit} disabled={ !query.trim() || - objectsQuery.isExecuting || - !objectsQuery.isReady + rowsQuery.isExecuting || + !rowsQuery.isReady } colorPalette="primary" > @@ -148,13 +148,13 @@ const RunGraphQLTab: React.FC = () => { {/* Error Display */} - {objectsQuery.error && ( + {rowsQuery.error && ( Query Error