Skip to content

Commit

Permalink
Prettier updates. Sanitizing relationship classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-in-ict committed Feb 22, 2022
1 parent cb39182 commit 685e469
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/integration-sdk-cli/src/neo4j/neo4jGraphStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Entity, Relationship } from '@jupiterone/integration-sdk-core';
import { sanitizeValue, buildPropertyParameters, sanitizePropertyName } from './neo4jUtilities';
import {
sanitizeValue,
buildPropertyParameters,
sanitizePropertyName,
} from './neo4jUtilities';

import * as neo4j from 'neo4j-driver';

Expand Down Expand Up @@ -53,11 +57,10 @@ export class Neo4jGraphStore {
for (const entity of newEntities) {
let classLabels = '';
if (entity._class) {
if(typeof(entity._class) === 'string') {
if (typeof entity._class === 'string') {
classLabels += `:${sanitizePropertyName(entity._class)}`;
}
else {
for(const className of entity._class) {
} else {
for (const className of entity._class) {
classLabels += `:${sanitizePropertyName(className)}`;
}
}
Expand Down Expand Up @@ -132,10 +135,14 @@ export class Neo4jGraphStore {
);
}

const sanitizedRelationshipClass = sanitizePropertyName(
relationship._class,
);

const buildCommand = `
MERGE (start {_key: $startEntityKey, _integrationInstanceID: $integrationInstanceID})
MERGE (end {_key: $endEntityKey, _integrationInstanceID: $integrationInstanceID})
MERGE (start)-[${relationshipAlias}:${relationship._class}]->(end)
MERGE (start)-[${relationshipAlias}:${sanitizedRelationshipClass}]->(end)
SET ${relationshipAlias} += $propertyParameters;`;
await this.runCypherCommand(buildCommand, {
propertyParameters: propertyParameters,
Expand Down

0 comments on commit 685e469

Please sign in to comment.