Skip to content

Commit 13e76bc

Browse files
authored
Delete issue fix
* Corrected an issue with delete * Removed duplicated functions
1 parent 6c4bdac commit 13e76bc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
**v0.1.3, to be released on ???**
2+
* Bug fix: Corrected an issue when trying to delete non-existing objects/edges.
23
* Bug fix: small bug fix in addPossibleTypes for queries; see: https://github.com/LiUGraphQL/woo.sh/commit/514a8e01acceab355a0e4729b1b1a6de2a6ee2df
34

5+
46
**v0.1.2, to be released on August 19, 2020**
57
* New feature: Changed Edge validation behaviour to not check for existance of documents created in the same mutation. See: https://github.com/LiUGraphQL/woo.sh/pull/98
68
* New feature: Individual edges can now by queried by ID

graphql-server/drivers/arangodb/driver.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ function update(isRoot, ctxt, varOrID, data, returnType, info, resVar = null) {
696696
validateKey(ctxt, resVar, returnType, info);
697697
// directives handling
698698
let resVarId = isVar(resVar) ? resVar : addParameterVar(ctxt, createParamVar(ctxt), { '_id': resVar });
699-
700699
addFinalDirectiveChecksForType(ctxt, returnType, asAQLVar(resVarId), info.schema);
701700
// return promises for roots and null for nested result
702701
return isRoot ? getResult(ctxt, info, resVar) : null;
@@ -718,7 +717,6 @@ function deleteEdge(isRoot, ctxt, id, edgeName, sourceType, info, resVar = null)
718717
// init transaction
719718
initTransaction(ctxt);
720719
ctxt.trans.code.push(`\n\t/* delete edge ${edgeName} */`);
721-
722720
let idVar = addParameterVar(ctxt, createParamVar(ctxt), id);
723721

724722
// create a new resVar if not defined by the calling function, resVar is the source vertex for all edges
@@ -727,10 +725,12 @@ function deleteEdge(isRoot, ctxt, id, edgeName, sourceType, info, resVar = null)
727725

728726
// return null if the key does not exists in the collection (i.e., don't throw error)
729727
ctxt.trans.code.push(`let ${resVar} = db._query(aql\`REMOVE PARSE_IDENTIFIER(${asAQLVar(idVar)}).key IN ${asAQLVar(collectionVar)} OPTIONS { ignoreErrors: true } RETURN OLD\`).next();`);
728+
ctxt.trans.code.push(`if(${resVar}){`);
730729

731730
// directives handling
732731
addFinalDirectiveChecksForType(ctxt, sourceType, aql`${asAQLVar(resVar)}._source`, info.schema);
733732
// return promises for roots and null for nested result
733+
ctxt.trans.code.push(`}`);
734734
return isRoot ? getResult(ctxt, info, resVar) : null;
735735
}
736736

@@ -762,6 +762,7 @@ function deleteObject(isRoot, ctxt, varOrID, typeToDelete, info, resVar = null)
762762
// delete document
763763
// return null if the key does not exists in the collection (i.e., don't throw error)
764764
ctxt.trans.code.push(`let ${resVar} = db._query(aql\`REMOVE PARSE_IDENTIFIER(${asAQLVar(idVar)}).key IN ${asAQLVar(collectionVar)} OPTIONS { ignoreErrors: true } RETURN OLD\`).next();`);
765+
ctxt.trans.code.push(`if(${resVar}){`);
765766

766767
// delete every edge either targeting, or originating from id
767768
for (let i in typeToDelete.getFields()) {
@@ -796,6 +797,7 @@ function deleteObject(isRoot, ctxt, varOrID, typeToDelete, info, resVar = null)
796797
// directives handling
797798
addFinalDirectiveChecksForType(ctxt, typeToDelete, aql`${asAQLVar(resVar)}._id`, info.schema);
798799
// return promises for roots and null for nested result
800+
ctxt.trans.code.push(`}`);
799801
return isRoot ? getResult(ctxt, info, resVar) : null;
800802
}
801803

0 commit comments

Comments
 (0)