Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
{ "ignoreConsecutiveComments": true }
],
"eslint/curly": ["error", "multi-line"],
"node/no-top-level-await": "off",
"oxc/no-optional-chaining": "off",
"oxc/no-async-await": "off",
"eslint/eqeqeq": ["off", "smart"],
Expand All @@ -42,6 +41,7 @@
"eslint/no-eq-null": "off",
"eslint/no-magic-numbers": "off",
"eslint/no-ternary": "off",
"eslint/no-negated-condition": "off",
"eslint/no-nested-ternary": "off",
"eslint/no-undefined": "off",
"eslint/no-void": "off",
Expand Down
1 change: 1 addition & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ min_version = "2026.6.10"
"aqua:dahlia/hongdown" = "0.4.3"
"github:nushell/nushell" = "0.114.1"
node = "26"
"npm:@fedify/cli" = "2.4.0-dev.1758"
"npm:oxlint" = "1.75.0"
"npm:oxlint-tsgolint" = "7.0.2001"
"npm:pglite-cli" = "0.0.1"
Expand Down
5 changes: 5 additions & 0 deletions packages/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
"types": "./dist/account.d.mts",
"default": "./dist/account.mjs"
},
"./actor": {
"types": "./dist/actor.d.mts",
"default": "./dist/actor.mjs"
},
"./builder": {
"types": "./dist/builder.d.mts",
"default": "./dist/builder.mjs"
Expand All @@ -71,6 +75,7 @@
"entry": [
"src/index.ts",
"src/account.ts",
"src/actor.ts",
"src/builder.ts",
"src/instance.ts",
"src/schema.ts"
Expand Down
98 changes: 97 additions & 1 deletion packages/graphql/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { drizzleConnectionHelpers } from "@pothos/plugin-drizzle";
import { and, eq, isNotNull } from "drizzle-orm/sql/expressions";

import builder, { type DrFedObjectRef } from "./builder.ts";
// oxlint-disable-next-line import/no-cycle
import { Instance } from "./instance.ts";

const AccountRef = builder.drizzleNode("accounts", {
Expand Down Expand Up @@ -170,3 +169,100 @@ builder.queryFields((t) => ({
type: AccountRef,
}),
}));

const instanceMembersConnection = drizzleConnectionHelpers(
builder,
"instanceMembers",
{
query: {
orderBy: { created: "desc" },
},
select(nestedSelection) {
return {
with: {
account: nestedSelection(),
},
where: {
accepted: { isNotNull: true },
},
};
},
resolveNode(instanceMember) {
return instanceMember.account;
},
},
);

builder.drizzleObjectField("instances", "members", (t) =>
t.connection(
{
type: Account,
description: "The `Account`s that belong to the `Instance`.",
select(args, ctx, nestedSelection) {
return {
with: {
instanceMembers: instanceMembersConnection.getQuery(
args,
ctx,
nestedSelection,
),
},
};
},
resolve(instance, args, ctx) {
return {
...instanceMembersConnection.resolve(
instance.instanceMembers,
args,
ctx,
instance,
),
totalCount() {
return ctx.db.$count(
instanceMembers,
and(
eq(instanceMembers.instanceId, instance.id),
isNotNull(instanceMembers.accepted),
),
);
},
};
},
},
{
fields(fb) {
return {
totalCount: fb.int({
description:
"The total number of `Account`s that belong to the `Instance`. " +
"Note that pending members are not counted.",
resolve(connection) {
return connection.totalCount();
},
}),
};
},
},
{
fields(fb) {
return {
created: fb.expose("created", {
type: "DateTime",
description:
"The date/time when the `Account` was added to the `Instance`.",
}),
accepted: fb.expose("accepted", {
type: "DateTime",
nullable: true,
description:
"The date/time when the `Account` accepted membership in the `Instance`.",
}),
admin: fb.exposeBoolean("admin", {
description:
"Whether the `Account` has administrator privileges in the `Instance`.",
}),
};
},
},
),
);
Loading