Skip to content

Commit

Permalink
Merge branch 'main' into 62-use-bun-for-the-api
Browse files Browse the repository at this point in the history
  • Loading branch information
bnussman committed Oct 31, 2023
2 parents 8f880e8 + fea6572 commit 15785af
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 173 deletions.
12 changes: 6 additions & 6 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
]
},
"dependencies": {
"@apollo/server": "^4.9.4",
"@apollo/server": "^4.9.5",
"@banksnussman/graphql-fields-to-relations": "^2.0.0",
"@mikro-orm/core": "5.9.0",
"@mikro-orm/postgresql": "5.9.0",
"@sentry/integrations": "^7.75.1",
"@sentry/node": "^7.75.1",
"aws-sdk": "^2.1481.0",
"@sentry/integrations": "^7.77.0",
"@sentry/node": "^7.77.0",
"aws-sdk": "^2.1485.0",
"body-parser": "^1.20.2",
"car-info": "^0.1.5",
"class-validator": "^0.14.0",
Expand All @@ -45,7 +45,7 @@
"js-sha256": "^0.10.1",
"nodemailer": "^6.9.7",
"reflect-metadata": "^0.1.13",
"type-graphql": "2.0.0-beta.2",
"type-graphql": "2.0.0-beta.3",
"uuid": "^9.0.1",
"wkx": "^0.5.0",
"ws": "^8.14.2"
Expand All @@ -56,7 +56,7 @@
"@types/body-parser": "^1.19.4",
"@types/cors": "^2.8.15",
"@types/express": "^4.17.20",
"@types/node": "^20.8.9",
"@types/node": "^20.8.10",
"@types/nodemailer": "^6.4.13",
"@types/uuid": "^9.0.6",
"@types/ws": "^8.5.8",
Expand Down
9 changes: 3 additions & 6 deletions api/src/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLError, GraphQLFormattedError } from "graphql";
import { unwrapResolverError } from '@apollo/server/errors';
import { ValidationError as ClassValidatorError } from 'class-validator';

export class ValidationError extends GraphQLError {
public constructor(validationErrors: any) {
Expand All @@ -15,11 +15,8 @@ export class ValidationError extends GraphQLError {
}

export function formatError(formattedError: GraphQLFormattedError, error: any) {
const originalError = unwrapResolverError(error);

if (error?.message === "Argument Validation Error") {
// @ts-expect-error fix types here
const errors = originalError.validationErrors;
const errors = formattedError.extensions!.validationErrors as ClassValidatorError[];

const output: { [key: string]: string[] } = {};

Expand All @@ -35,4 +32,4 @@ export function formatError(formattedError: GraphQLFormattedError, error: any) {
}

return formattedError;
}
}
2 changes: 1 addition & 1 deletion api/src/utils/pagination.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ClassType, Field, Int, ObjectType, ArgsType } from 'type-graphql';
import { IsNumber, Max, Min } from 'class-validator';

export function Paginated<T>(TItemClass: ClassType<T>) {
export function Paginated<T extends object>(TItemClass: ClassType<T>) {
@ObjectType()
abstract class PaginatedResponseClass {
@Field(() => [TItemClass])
Expand Down
Loading

0 comments on commit 15785af

Please sign in to comment.