Skip to content

Commit

Permalink
Upgrade pothos, prisma, and TypeScript for gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
knpwrs committed Dec 20, 2024
1 parent cd2d20c commit 9e9b160
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 25 deletions.
Binary file modified services/gateway/bun.lockb
Binary file not shown.
24 changes: 12 additions & 12 deletions services/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
18 changes: 12 additions & 6 deletions services/gateway/src/schema/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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: {
Expand Down
30 changes: 23 additions & 7 deletions services/gateway/src/schema/types/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,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,
Expand All @@ -380,8 +381,8 @@ const UploadRecord = builder.prismaObject('UploadRecord', {
]);

return {
totalCount,
...res,
totalCount,
};
},
},
Expand Down Expand Up @@ -592,17 +593,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,
Expand All @@ -615,8 +622,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: {
Expand Down Expand Up @@ -684,6 +698,7 @@ builder.queryFields((t) => ({
return resolveOffsetConnection({ args }, async ({ offset, limit }) => {
return prisma.uploadRecord.findMany({
...query,
select: query.select ?? null,
skip: offset,
take: limit,
where: {
Expand Down Expand Up @@ -725,6 +740,7 @@ builder.queryFields((t) => ({
return resolveOffsetConnection({ args }, async ({ offset, limit }) => {
return prisma.uploadRecord.findMany({
...query,
select: query.select ?? null,
skip: offset,
take: limit,
where: {
Expand Down

0 comments on commit 9e9b160

Please sign in to comment.