Skip to content

Commit

Permalink
Revert "typedSql"
Browse files Browse the repository at this point in the history
This reverts commit eef3d35.
  • Loading branch information
danielbuechele committed Sep 10, 2024
1 parent 65e0f0a commit 688a19d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": "bun src/index.ts",
"dev": "bun --watch src/index.ts",
"generate:prisma": "prisma generate --sql",
"generate:prisma": "prisma generate",
"generate:mail": "maizzle build production",
"generate:proto": "cd src/proto && protoc --experimental_allow_proto3_optional --plugin=../../node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=. ./*.proto --ts_proto_opt=esModuleInterop=true",
"generate:env": "bun dotenv-vault pull",
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch", "postgresqlExtensions", "typedSql"]
previewFeatures = ["fullTextSearch", "postgresqlExtensions"]
binaryTargets = ["native"]
}

Expand Down
3 changes: 0 additions & 3 deletions prisma/sql/getDirectusFileById.sql

This file was deleted.

3 changes: 0 additions & 3 deletions prisma/sql/getViewerFromDirectusId.sql

This file was deleted.

5 changes: 3 additions & 2 deletions src/models/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {SchemaTypes} from '@pothos/core';
import {GraphQLError} from 'graphql';
import {builder} from '../pothos/builder';
import prismaClient from '../utils/prismaClient';
import {getDirectusFileById} from '@prisma/client/sql';
import {resolveOffsetConnection} from '@pothos/plugin-relay';
import {
PrismaModelTypes,
Expand Down Expand Up @@ -113,7 +112,9 @@ export function pixelImageField<Types extends SchemaTypes, F extends string>(
return null;
}

const [row] = await prismaClient.$queryRawTyped(getDirectusFileById(id));
const [row] = await prismaClient.$queryRaw<
[DirectusFile?]
>`select * from "directus"."directus_files" where "id"=${id}::uuid`;

if (row == null || !row.height || !row.width) {
return null;
Expand Down
11 changes: 6 additions & 5 deletions src/utils/viewerIdFromToken.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import {ParsedToken} from '../routes/auth';
import prismaClient from './prismaClient';
import {getViewerFromDirectusId} from '@prisma/client/sql';

export default async function viewerIdFromToken(
parsedToken: ParsedToken | undefined,
): Promise<string | undefined> {
if (parsedToken == null) {
return;
} else if (parsedToken.iss === 'directus') {
const [user] = await prismaClient.$queryRawTyped(
getViewerFromDirectusId(parsedToken.id),
);
return user?.external_identifier ?? undefined;
const user = await prismaClient.$queryRaw<
Array<{
external_identifier: string;
}>
>`select "external_identifier" from "directus"."directus_users" where "id"=${parsedToken.id}::uuid`;
return user.pop()?.external_identifier;
} else if (parsedToken.iss === 'owntracks') {
return parsedToken.viewerId;
}
Expand Down

0 comments on commit 688a19d

Please sign in to comment.