-
Notifications
You must be signed in to change notification settings - Fork 14
Fluent Queries
Arun Prakash edited this page Sep 21, 2025
·
1 revision
A lightweight fluent layer sits atop the existing request classes to help you compose requests without manually instantiating them. This does not change the public interface types; it exposes convenient builders via client.<interface>.query
.
- Each interface (e.g.,
client.posts
) exposes aquery
getter that auto-seeds the appropriate list request (e.g.,ListPostRequest
). - You can chain helpers like
withPage
,withPerPage
,withSearch
,withOrder
,withOrderBy
, etc. - For params not covered by helpers, mutate the underlying seed via
configureSeed((seed) { ... })
or accessbuilder.seedRequest
directly. - This layer is non-breaking; the base CRUD mixins remain unchanged.
final res = await client.posts.query
.withPage(1)
.withPerPage(20)
.withSearch('welcome')
.withOrder(Order.desc)
.execute();
final res2 = await client.posts.query
.configureSeed((seed) {
seed.context = RequestContext.view;
})
.execute();
final builder = client.posts.query;
builder.seedRequest.context = RequestContext.view;
final res3 = await builder.execute();
-
withPage(int)
/withPerPage(int)
withSearch(String)
-
withOrder(Order)
/withOrderBy(String)
withContext(RequestContext)
-
withInclude(List<int>)
/withExclude(List<int>)
-
withCategories(List<int>)
/withTags(List<int>)
-
withAfter(DateTime)
/withBefore(DateTime)
-
withAuthor(List<int>)
/withAuthorExclude(List<int>)
-
withOffset(int)
/withSlug(List<String>)
/withStatus(List<ContentStatus>)
Note: Some auto-seeded builders (e.g., revisions/navigation) default to placeholder IDs. Set them via
configureSeed
(orseedRequest
) beforeexecute()
.