From 8f6d2b5f3c46925f1f7eabeb233ef9cb80b55957 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Wed, 16 Aug 2023 13:16:49 +0200 Subject: [PATCH] apply suggestions --- .../resolver/TransactionLinkResolver.test.ts | 57 +++++++++++++++++++ backend/src/graphql/schema.ts | 8 +-- backend/src/graphql/validator/Alias.ts | 0 3 files changed, 61 insertions(+), 4 deletions(-) delete mode 100644 backend/src/graphql/validator/Alias.ts diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 59e8047c6..fe047b35a 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -148,6 +148,63 @@ describe('TransactionLinkResolver', () => { ]) }) + it('throws error when memo text is too short', async () => { + jest.clearAllMocks() + const { errors: errorObjects } = await mutate({ + mutation: createTransactionLink, + variables: { + amount: 100, + memo: 'Test', + }, + }) + expect(errorObjects).toMatchObject([ + { + message: 'Argument Validation Error', + extensions: { + exception: { + validationErrors: [ + { + property: 'memo', + constraints: { + minLength: 'memo must be longer than or equal to 5 characters', + }, + }, + ], + }, + }, + }, + ]) + }) + + it('throws error when memo text is too long', async () => { + jest.clearAllMocks() + const { errors: errorObjects } = await mutate({ + mutation: createTransactionLink, + variables: { + identifier: 'peter@lustig.de', + amount: 100, + memo: 'test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test t', + }, + }) + expect(errorObjects).toMatchObject([ + { + message: 'Argument Validation Error', + extensions: { + exception: { + validationErrors: [ + { + property: 'memo', + constraints: { + maxLength: 'memo must be shorter than or equal to 255 characters', + }, + }, + ], + }, + }, + }, + ]) + }) + it('throws error when user has not enough GDD', async () => { jest.clearAllMocks() await expect( diff --git a/backend/src/graphql/schema.ts b/backend/src/graphql/schema.ts index 878bb747c..a2e4ca71f 100644 --- a/backend/src/graphql/schema.ts +++ b/backend/src/graphql/schema.ts @@ -14,11 +14,11 @@ export const schema = async (): Promise => { scalarsMap: [{ type: Decimal, scalar: DecimalScalar }], validate: { validationError: { target: false }, - skipMissingProperties: true, + skipMissingProperties: false, skipNullProperties: true, - skipUndefinedProperties: true, - forbidUnknownValues: false, - stopAtFirstError: false, + skipUndefinedProperties: false, + forbidUnknownValues: true, + stopAtFirstError: true, }, }) } diff --git a/backend/src/graphql/validator/Alias.ts b/backend/src/graphql/validator/Alias.ts deleted file mode 100644 index e69de29bb..000000000