feat(blog): add ui/query.ts (framework-agnostic React Query option builders)
This commit is contained in:
29
packages/blog/src/ui/query.ts
Normal file
29
packages/blog/src/ui/query.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// React Query option builders for blog feature procedures.
|
||||||
|
// Consumed by apps via the @repo/core-trpc client (wired in Plan 5).
|
||||||
|
|
||||||
|
type TrpcClient = {
|
||||||
|
blog: {
|
||||||
|
articleBySlug: {
|
||||||
|
queryOptions: (input: { slug: string }) => unknown;
|
||||||
|
};
|
||||||
|
listArticles: {
|
||||||
|
queryOptions: (input?: {
|
||||||
|
status?: string;
|
||||||
|
authorId?: string;
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
}) => unknown;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function articleBySlugQuery(client: TrpcClient, slug: string) {
|
||||||
|
return client.blog.articleBySlug.queryOptions({ slug });
|
||||||
|
}
|
||||||
|
|
||||||
|
export function listArticlesQuery(
|
||||||
|
client: TrpcClient,
|
||||||
|
options?: { status?: string; authorId?: string; limit?: number; offset?: number },
|
||||||
|
) {
|
||||||
|
return client.blog.listArticles.queryOptions(options);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user