Skip to content

Commit

Permalink
Return two items from a Cypher query
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmith committed Nov 20, 2020
1 parent 38c25a2 commit 6284214
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"cSpell.words": [
"Dbclick",
"Netlify"
]
],
"vetur.experimental.templateInterpolationService": true
}
2 changes: 1 addition & 1 deletion packages/frontend/src/components/NodeFormCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</b-select>
</b-field>

<b-field v-if="definition.showRelatedTo" label="Related To" style="display: flex; flex-direction: column">
<b-field v-if="definition && definition.showRelatedTo" label="Related To" style="display: flex; flex-direction: column">
<div v-if="relatedToLabel" style="margin-top: -0.3em; display: flex; align-items: center; justify-content: space-between">
<div>
{{ relatedToLabel }}
Expand Down
15 changes: 8 additions & 7 deletions packages/frontend/src/components/QueryCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,18 @@ export default createComponent({
const nodesType = array(type);
const maybeNodes: unknown[] = [];
for (const items of result.items) {
if (items.length > 1) {
notifier.danger('Your query was successful but should only return 1 item from your query.');
return;
}
// The query returns a arrays of arrays
// Each element of the array should be the same length
// e.g. the below query returns an array of arrays of length 2
// MATCH (n:ProvenanceNode) <-[:DEPENDS*]- (p:ProvenanceNode) WHERE n.definitionId = "Model" RETURN n,p;
for (const items of result.items) {
if (items.length === 0) {
notifier.info('Your query was successful but returned nothing.');
notifier.info('Your query was successfull but returned nothing.');
return;
}
maybeNodes.push(items[0]);
maybeNodes.push(...items);
}
const decodeResult = nodesType.decode(maybeNodes);
Expand Down

0 comments on commit 6284214

Please sign in to comment.