Skip to content

Parallel Queries

Fasq is designed to handle multiple concurrent queries efficiently. When you use multiple QueryBuilder widgets in the same screen, they fetch in parallel automatically.

Simply use multiple query widgets side-by-side (e.g., in a Column).

Column(
children: [
QueryBuilder<User>(
queryKey: 'user'.toQueryKey(),
builder: /* ... */,
),
QueryBuilder<List<Post>>(
queryKey: 'posts'.toQueryKey(),
builder: /* ... */,
),
],
)
  1. Independent Execution: Each query runs its own async operation.
  2. Non-Blocking: One slow query does not stop the others from loading.
  3. Deduplication: If two components request the same key, only one network request is made.

If you need to fetch a dynamic list of items (e.g. valid IDs), mapping them to queries works seamlessly.

// Fetching multiple posts by ID in parallel
Column(
children: postIds.map((id) =>
QueryBuilder(
queryKey: 'post:$id'.toQueryKey(),
queryFn: () => api.fetchPost(id),
builder: (context, state) => PostTile(state.data),
)
).toList(),
)