Skip to content

Commit 5b17177

Browse files
committed
feat(graphql): add viewerBlocks field in actor
Signed-off-by: Haze Lee <hazelee@realignist.me>
1 parent c21d33b commit 5b17177

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

graphql/actor.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,21 @@ builder.drizzleObjectFields(Actor, (t) => ({
335335
}) != null;
336336
},
337337
}),
338+
viewerBlocks: t.field({
339+
type: "Boolean",
340+
async resolve(actor, _, ctx) {
341+
if (ctx.account == null || ctx.account.actor == null) {
342+
return false;
343+
}
344+
return await ctx.db.query.blockingTable.findFirst({
345+
columns: { iri: true },
346+
where: {
347+
blockerId: ctx.account.actor.id,
348+
blockeeId: actor.id,
349+
},
350+
}) != null;
351+
},
352+
}),
338353
followsViewer: t.field({
339354
type: "Boolean",
340355
async resolve(actor, _, ctx) {

graphql/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ type Actor implements Node {
157157
url: URL
158158
username: String!
159159
uuid: UUID!
160+
viewerBlocks: Boolean!
160161
viewerFollows: Boolean!
161162
}
162163

0 commit comments

Comments
 (0)