From 5f1bd0faae37180512202ab2fa939403d2e9bd3b Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 24 Jun 2024 12:38:33 +0200 Subject: [PATCH] fix lint --- backend/src/graphql/input/EditCommunityInput.ts | 8 ++++---- backend/src/graphql/model/Point.ts | 1 + backend/src/graphql/resolver/CommunityResolver.ts | 4 ++-- backend/src/graphql/scalar/Point.ts | 6 ++++-- backend/src/graphql/validator/Point.ts | 1 + 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/backend/src/graphql/input/EditCommunityInput.ts b/backend/src/graphql/input/EditCommunityInput.ts index d36a6d6b7..560ef3fcd 100644 --- a/backend/src/graphql/input/EditCommunityInput.ts +++ b/backend/src/graphql/input/EditCommunityInput.ts @@ -11,11 +11,11 @@ export class EditCommunityInput { @IsUUID('4') uuid: string - @Field(() => String, {nullable: true}) + @Field(() => String, { nullable: true }) @IsString() - gmsApiKey: string | null + gmsApiKey?: string | null - @Field(() => Point, {nullable: true}) + @Field(() => Point, { nullable: true }) @isValidPoint() - location: Point | null + location?: Point | null } diff --git a/backend/src/graphql/model/Point.ts b/backend/src/graphql/model/Point.ts index bddb50598..45c4c3a29 100644 --- a/backend/src/graphql/model/Point.ts +++ b/backend/src/graphql/model/Point.ts @@ -5,6 +5,7 @@ export class Point implements geojsonPoint { this.coordinates = [] this.type = 'Point' } + type: 'Point' coordinates: Position } diff --git a/backend/src/graphql/resolver/CommunityResolver.ts b/backend/src/graphql/resolver/CommunityResolver.ts index 0dc844b5c..4299dceb1 100644 --- a/backend/src/graphql/resolver/CommunityResolver.ts +++ b/backend/src/graphql/resolver/CommunityResolver.ts @@ -89,8 +89,8 @@ export class CommunityResolver { throw new LogError('Error: Only the HomeCommunity could be modified!') } if (homeCom.gmsApiKey !== gmsApiKey || homeCom.location !== location) { - homeCom.gmsApiKey = gmsApiKey - homeCom.location = location + homeCom.gmsApiKey = gmsApiKey ?? null + homeCom.location = location ?? null await DbCommunity.save(homeCom) } return new Community(homeCom) diff --git a/backend/src/graphql/scalar/Point.ts b/backend/src/graphql/scalar/Point.ts index 015704a15..5e4b7a53b 100644 --- a/backend/src/graphql/scalar/Point.ts +++ b/backend/src/graphql/scalar/Point.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ import { GraphQLScalarType, Kind } from 'graphql' + import { Point } from '@/graphql/model/Point' export const PointScalar = new GraphQLScalarType({ @@ -10,14 +11,15 @@ export const PointScalar = new GraphQLScalarType({ serialize(value: Point) { // Check type of value if (value.type !== 'Point') { - throw new Error(`PointScalar can only serialize Geometry type 'Point' values`, ) + throw new Error(`PointScalar can only serialize Geometry type 'Point' values`) } return value }, parseValue(value): Point { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (value.type !== 'Point') { - throw new Error(`PointScalar can only deserialize Geometry type 'Point' values`, ) + throw new Error(`PointScalar can only deserialize Geometry type 'Point' values`) } return value as Point }, diff --git a/backend/src/graphql/validator/Point.ts b/backend/src/graphql/validator/Point.ts index 0e4c90e38..923fcf99e 100644 --- a/backend/src/graphql/validator/Point.ts +++ b/backend/src/graphql/validator/Point.ts @@ -1,4 +1,5 @@ import { registerDecorator, ValidationOptions, ValidationArguments } from 'class-validator' + import { Point } from '@/graphql/model/Point' export function isValidPoint(validationOptions?: ValidationOptions) {