From d1111f8c942f8f599bd7a3f6d5061b0d745b939f Mon Sep 17 00:00:00 2001 From: Carson Full Date: Wed, 29 May 2024 14:41:22 -0500 Subject: [PATCH 1/2] Add `DtoRepo.delete` to replace `deleteNode` This query is specific to the resource type of the class. It also matches the EdgeDB version so migration should be seamless --- src/core/database/dto.repository.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/database/dto.repository.ts b/src/core/database/dto.repository.ts index 5ca1d1fe8b..6be5ba47d2 100644 --- a/src/core/database/dto.repository.ts +++ b/src/core/database/dto.repository.ts @@ -16,7 +16,7 @@ import { DbChanges, getChanges } from './changes'; import { CommonRepository } from './common.repository'; import { DbTypeOf } from './db-type'; import { OnIndex } from './indexer'; -import { matchProps } from './query'; +import { deleteBaseNode, matchProps } from './query'; export const privileges = Symbol.for('DtoRepository.privileges'); @@ -104,6 +104,15 @@ export const DtoRepository = < .run(); } + async delete(id: ID) { + const query = this.db + .query() + .matchNode('node', this.resource.dbLabel, { id }) + .apply(deleteBaseNode('node')) + .return('*'); + await query.run(); + } + protected async updateProperties< TObject extends Partial> & { id: ID; From a9bf1ad2ed630783361fe5b510f57842232b53ab Mon Sep 17 00:00:00 2001 From: Carson Full Date: Wed, 29 May 2024 15:24:52 -0500 Subject: [PATCH 2/2] Mask generic Neo4j errors just like with EdgeDB --- src/core/exception/exception.normalizer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/exception/exception.normalizer.ts b/src/core/exception/exception.normalizer.ts index 2f905b63ed..902cfee2cf 100644 --- a/src/core/exception/exception.normalizer.ts +++ b/src/core/exception/exception.normalizer.ts @@ -138,7 +138,7 @@ export class ExceptionNormalizer { if (ex instanceof ExclusivityViolationError) { ex = DuplicateException.fromDB(ex, gqlContext); - } else if (ex instanceof Edge.EdgeDBError) { + } else if (ex instanceof Edge.EdgeDBError || Neo.isNeo4jError(ex)) { // Mask actual DB error with a nicer user error message. let message = 'Failed'; if (gqlContext) {