Skip to content
gpui-query logogpui-query

Navigation

Frequently Asked Questions

Common questions about gpui-query, grouped by topic.

Getting Started

How is gpui-query different from TanStack Query?

gpui-query adapts TanStack Query's patterns to Rust and the GPUI framework. It uses Rust's type system for compile-time guarantees, Arc<AtomicBool> for cooperative cancellation, and integrates directly with GPUI's render loop.

Can I use gpui-query outside of Zed?

gpui-query is designed for the GPUI framework, which powers the Zed editor. While architecturally the Core layer is framework-agnostic, the Hook layer depends on GPUI's reactive primitives.

How do I set up QueryClient in my app?

Create a QueryClient instance and register it in your GPUI application. The client manages all query resources, caching, and garbage collection. See the Getting Started guide.

Architecture

Why does use_query return a tuple instead of an object?

use_query returns (Entity<QueryResource<T, E>>, Subscription). Read data and status from the resource entity during render, and store the Subscription to keep the observation alive: dropping it stops updates, which is GPUI's standard lifecycle convention.

What happens if my component unmounts during a fetch?

gpui-query uses cooperative cancellation via QuerySignal (Arc<AtomicBool>). When a component unmounts, the signal is set and the query checks it between retry attempts.

What is QuerySignal and when do I check it?

QuerySignal is an Arc<AtomicBool> that enables cooperative cancellation. Long-running queries should check the signal periodically (especially between retry attempts) and abort early if cancelled.

Advanced

Why does LatestWins cancel my in-flight request?

LatestWins is a RequestPolicy that ensures only the most recent request's result is used. When a new request arrives, previous in-flight requests are cancelled via their signals, which prevents stale data from overwriting fresh results.

How do I persist my query cache?

Enable the persist feature and implement the async Persister trait to save and restore query state across restarts. gpui-query supports custom backends (files, databases, KV) and ships a ready-made disk adapter in the gpui-query-persist crate.

How do I handle pagination?

Use use_infinite_query for paginated data. It supports bidirectional fetching (fetch_next_page_infinite / fetch_previous_page_infinite) and configurable max_pages to limit cached pages.

Is there a devtools experience?

gpui-query provides ClientDiagnostic types for inspecting cache state, query status, and resource lifecycle.

Ask on GitHub.

If the answer is not here, open an issue and we will get back to you.

↑↓NavigateEnterOpenEscClose
Powered by Pagefind