fix: add adminGetVideo/adminGetArticle queries to fix 404 on edit pages
The edit page loaders were calling adminListVideos/adminListArticles with the old pre-pagination signatures and filtering by ID client-side, which broke after pagination limited results to 50. Now fetches the single item by ID directly via new adminGetVideo and adminGetArticle backend queries. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -96,6 +96,26 @@ builder.queryField("article", (t) =>
|
||||
}),
|
||||
);
|
||||
|
||||
builder.queryField("adminGetArticle", (t) =>
|
||||
t.field({
|
||||
type: ArticleType,
|
||||
nullable: true,
|
||||
args: {
|
||||
id: t.arg.string({ required: true }),
|
||||
},
|
||||
resolve: async (_root, args, ctx) => {
|
||||
requireAdmin(ctx);
|
||||
const article = await ctx.db
|
||||
.select()
|
||||
.from(articles)
|
||||
.where(eq(articles.id, args.id))
|
||||
.limit(1);
|
||||
if (!article[0]) return null;
|
||||
return enrichArticle(ctx.db, article[0]);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
// ─── Admin queries & mutations ────────────────────────────────────────────────
|
||||
|
||||
builder.queryField("adminListArticles", (t) =>
|
||||
|
||||
@@ -188,6 +188,22 @@ builder.queryField("video", (t) =>
|
||||
}),
|
||||
);
|
||||
|
||||
builder.queryField("adminGetVideo", (t) =>
|
||||
t.field({
|
||||
type: VideoType,
|
||||
nullable: true,
|
||||
args: {
|
||||
id: t.arg.string({ required: true }),
|
||||
},
|
||||
resolve: async (_root, args, ctx) => {
|
||||
requireAdmin(ctx);
|
||||
const video = await ctx.db.select().from(videos).where(eq(videos.id, args.id)).limit(1);
|
||||
if (!video[0]) return null;
|
||||
return enrichVideo(ctx.db, video[0]);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
builder.queryField("videoLikeStatus", (t) =>
|
||||
t.field({
|
||||
type: VideoLikeStatusType,
|
||||
|
||||
Reference in New Issue
Block a user