diff --git a/services/gateway/bun.lockb b/services/gateway/bun.lockb index e3baae83..198cabd5 100755 Binary files a/services/gateway/bun.lockb and b/services/gateway/bun.lockb differ diff --git a/services/gateway/package.json b/services/gateway/package.json index ca7b579c..3b12e62d 100644 --- a/services/gateway/package.json +++ b/services/gateway/package.json @@ -71,15 +71,15 @@ "@inquirer/prompts": "^1.0.1", "@knpwrs/envariant": "^1.1.1", "@node-rs/xxhash": "^1.7.6", - "@pothos/core": "^3.41.0", - "@pothos/plugin-errors": "^3.11.1", - "@pothos/plugin-prisma": "^3.63.1", - "@pothos/plugin-relay": "^3.46.0", - "@pothos/plugin-scope-auth": "^3.20.0", - "@pothos/plugin-simple-objects": "^3.7.0", - "@pothos/plugin-tracing": "^0.5.8", - "@pothos/plugin-validation": "^3.10.1", - "@prisma/client": "^5.22.0", + "@pothos/core": "^4.3.0", + "@pothos/plugin-errors": "^4.2.0", + "@pothos/plugin-prisma": "^4.4.0", + "@pothos/plugin-relay": "^4.3.0", + "@pothos/plugin-scope-auth": "^4.1.1", + "@pothos/plugin-simple-objects": "^4.1.0", + "@pothos/plugin-tracing": "^1.1.0", + "@pothos/plugin-validation": "^3.10.2", + "@prisma/client": "^6.1.0", "@sentry/node": "^8.47.0", "@sindresorhus/slugify": "^2.2.1", "@temporalio/activity": "^1.11.5", @@ -160,10 +160,10 @@ "eslint-plugin-import": "npm:eslint-plugin-i@^2.28.1", "npm-run-all": "^4.1.5", "prettier": "^3.4.2", - "prisma": "^5.22.0", + "prisma": "^6.1.0", "tsx": "^4.19.2", - "type-fest": "^3.6.1", - "typescript": "^5.2.2", + "type-fest": "^4.30.2", + "typescript": "^5.7.2", "vitest": "^2.1.8" } } diff --git a/services/gateway/src/schema/builder.ts b/services/gateway/src/schema/builder.ts index 1afdc4f3..d7323beb 100644 --- a/services/gateway/src/schema/builder.ts +++ b/services/gateway/src/schema/builder.ts @@ -18,6 +18,8 @@ import type { Scalars } from './scalars'; const moduleLogger = logger.child({ module: 'schema/builder' }); export default new SchemaBuilder<{ + // TODO: v4 upgrade: set nullability throughout types + DefaultFieldNullability: false; PrismaTypes: PrismaTypes; DefaultEdgesNullability: false; DefaultNodeNullability: false; @@ -43,16 +45,20 @@ export default new SchemaBuilder<{ SimpleObjectsPlugin, ValidationPlugin, ], - authScopes: ({ session }) => ({ - authenticated: !!session, - unauthenticated: !session, - admin: session?.appUser.role === 'ADMIN', - }), + // TODO: v4 upgrade: set nullability throughout types + defaultFieldNullability: false, + scopeAuth: { + authScopes: ({ session }) => ({ + authenticated: !!session, + unauthenticated: !session, + admin: session?.appUser.role === 'ADMIN', + }), + }, prisma: { client: prisma, filterConnectionTotalCount: true, }, - relayOptions: { + relay: { clientMutationId: 'omit', cursorType: 'String', edgesFieldOptions: { diff --git a/services/gateway/src/schema/types/upload.ts b/services/gateway/src/schema/types/upload.ts index 6c948ab2..3636b55a 100644 --- a/services/gateway/src/schema/types/upload.ts +++ b/services/gateway/src/schema/types/upload.ts @@ -76,7 +76,7 @@ const UploadUserComment = builder.prismaObject('UploadUserComment', { fields: (t) => ({ id: t.expose('id', { type: 'ShortUuid' }), uploadRecordId: t.expose('uploadRecordId', { type: 'ShortUuid' }), - replyingTo: t.relation('replyingTo'), + replyingTo: t.relation('replyingTo', { nullable: true }), createdAt: t.field({ type: 'DateTime', select: { @@ -200,6 +200,7 @@ const UploadRecord = builder.prismaObject('UploadRecord', { createdBy: t.relation('createdBy', { authScopes: internalAuthScopes }), uploadFinalizedBy: t.relation('uploadFinalizedBy', { authScopes: internalAuthScopes, + nullable: true, }), variants: t.expose('variants', { type: [UploadVariantEnum], @@ -368,6 +369,7 @@ const UploadRecord = builder.prismaObject('UploadRecord', { }); return prisma.uploadUserComment.findMany({ ...query, + select: query.select ?? null, where: { uploadRecordId: root.id, replyingTo: null }, skip: offset, take: limit, @@ -380,8 +382,8 @@ const UploadRecord = builder.prismaObject('UploadRecord', { ]); return { - totalCount, ...res, + totalCount, }; }, }, @@ -592,17 +594,23 @@ const UploadRecord = builder.prismaObject('UploadRecord', { type: UploadList, select: { id: true }, resolve: (root, args, context, info) => - resolveOffsetConnection({ args }, async ({ offset, limit }) => - prisma.uploadList.findMany({ - ...queryFromInfo({ context, info, path: ['edges', 'node'] }), + resolveOffsetConnection({ args }, async ({ offset, limit }) => { + const query = queryFromInfo({ + context, + info, + path: ['edges', 'node'], + }); + return prisma.uploadList.findMany({ + ...query, + select: query.select ?? null, skip: offset, take: limit, where: { type: UploadListType.SERIES, uploads: { some: { uploadRecordId: root.id } }, }, - }), - ), + }); + }), }), playlists: t.connection({ type: UploadList, @@ -615,8 +623,15 @@ const UploadRecord = builder.prismaObject('UploadRecord', { return []; } + const query = queryFromInfo({ + context, + info, + path: ['edges', 'node'], + }); + return prisma.uploadList.findMany({ - ...queryFromInfo({ context, info, path: ['edges', 'node'] }), + ...query, + select: query.select ?? null, skip: offset, take: limit, where: { @@ -684,6 +699,7 @@ builder.queryFields((t) => ({ return resolveOffsetConnection({ args }, async ({ offset, limit }) => { return prisma.uploadRecord.findMany({ ...query, + select: query.select ?? null, skip: offset, take: limit, where: { @@ -725,6 +741,7 @@ builder.queryFields((t) => ({ return resolveOffsetConnection({ args }, async ({ offset, limit }) => { return prisma.uploadRecord.findMany({ ...query, + select: query.select ?? null, skip: offset, take: limit, where: {