Skip to content

Commit

Permalink
feat(explorer): enable re-executing query (#3471)
Browse files Browse the repository at this point in the history
  • Loading branch information
karooolis authored Jan 21, 2025
1 parent 3fa2ed1 commit 3264908
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-countries-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/explorer": patch
---

Previously, queries could only be executed if they had changed, as data fetching was tied to query updates. Now, it’s possible to trigger a new table data fetch explicitly, regardless of whether the query has changed.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function SQLEditor({ table, isLiveQuery, setIsLiveQuery }: Props) {
const [isFocused, setIsFocused] = useState(false);
const [query, setQuery] = useQueryState("query", { defaultValue: "" });
const validateQuery = useQueryValidator(table);
const { data: tableData } = useTableDataQuery({
const { data: tableData, refetch } = useTableDataQuery({
table,
query,
isLiveQuery,
Expand All @@ -45,6 +45,7 @@ export function SQLEditor({ table, isLiveQuery, setIsLiveQuery }: Props) {
const handleSubmit = form.handleSubmit((data) => {
if (validateQuery(data.query)) {
setQuery(data.query);
refetch();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ export function TablesViewer({ table, query, isLiveQuery }: Props) {
const {
data: tableData,
isLoading: isTDataLoading,
isRefetching,
isFetched,
isError,
error,
} = useTableDataQuery({ table, query, isLiveQuery });
const isLoading = isTDataLoading || !isFetched;
const isLoading = isTDataLoading || isRefetching || !isFetched;
const [globalFilter, setGlobalFilter] = useQueryState("filter", parseAsString.withDefault(""));
const [sorting, setSorting] = useQueryState("sort", parseAsJson<SortingState>().withDefault(initialSortingState));

Expand Down

0 comments on commit 3264908

Please sign in to comment.