Skip to content

Commit 1bd30c5

Browse files
authored
Merge pull request #188 from biothings/empty-attributes
Add empty attributes property to node/edge bindings and aux-graphs
2 parents 0c1d167 + 112b775 commit 1bd30c5

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export default class TRAPIQueryHandler {
211211
suffix += 1;
212212
}
213213
const supportGraphID = `support${suffix}-${boundEdgeID}`;
214-
auxGraphs[supportGraphID] = { edges: supportGraph };
214+
auxGraphs[supportGraphID] = { edges: supportGraph, attributes: [] };
215215
if (!edgesIDsByAuxGraphID[supportGraphID]) {
216216
edgesIDsByAuxGraphID[supportGraphID] = new Set();
217217
}
@@ -254,7 +254,7 @@ export default class TRAPIQueryHandler {
254254
boundIDs.add(binding.id);
255255
}
256256
} else if (!boundIDs.has(nodesToRebind[binding.id].newNode)) {
257-
newBindings.push({ id: nodesToRebind[binding.id].newNode });
257+
newBindings.push({ id: nodesToRebind[binding.id].newNode, attributes: [] });
258258
boundIDs.add(nodesToRebind[binding.id].newNode);
259259
}
260260
return { boundIDs, newBindings };
@@ -276,7 +276,7 @@ export default class TRAPIQueryHandler {
276276
boundIDs.add(binding.id);
277277
}
278278
} else if (!boundIDs.has(edgesToRebind[binding.id])) {
279-
newBindings.push({ id: edgesToRebind[binding.id] });
279+
newBindings.push({ id: edgesToRebind[binding.id], attributes: [] });
280280
boundIDs.add(edgesToRebind[binding.id]);
281281
resultBoundEdgesWithAuxGraphs.add(edgesToRebind[binding.id]);
282282
}

src/inferred_mode/inferred_mode.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ export default class InferredQueryHandler {
288288
newResponse.message.results.forEach((result) => {
289289
const translatedResult: TrapiResult = {
290290
node_bindings: {
291-
[qEdge.subject]: [{ id: result.node_bindings.creativeQuerySubject[0].id }],
292-
[qEdge.object]: [{ id: result.node_bindings.creativeQueryObject[0].id }],
291+
[qEdge.subject]: [{ id: result.node_bindings.creativeQuerySubject[0].id, attributes: [] }],
292+
[qEdge.object]: [{ id: result.node_bindings.creativeQueryObject[0].id, attributes: [] }],
293293
},
294294
pfocr: result.pfocr?.length ? result.pfocr : undefined,
295295
analyses: [
@@ -311,14 +311,14 @@ export default class InferredQueryHandler {
311311
// Direct edge answers stand on their own, not as an inferred edge.
312312
if (Object.keys(result.node_bindings).length == 2) {
313313
const boundEdgeID = Object.values(result.analyses[0].edge_bindings)[0][0].id;
314-
translatedResult.analyses[0].edge_bindings = { [qEdgeID]: [{ id: boundEdgeID }] };
314+
translatedResult.analyses[0].edge_bindings = { [qEdgeID]: [{ id: boundEdgeID, attributes: [] }] };
315315
} else {
316316
// Create an aux graph using the result and associate it with an inferred Edge
317317
const inferredEdgeID = `inferred-${resultCreativeSubjectID}-${qEdge.predicates[0].replace(
318318
'biolink:',
319319
'',
320320
)}-${resultCreativeObjectID}`;
321-
translatedResult.analyses[0].edge_bindings = { [qEdgeID]: [{ id: inferredEdgeID }] };
321+
translatedResult.analyses[0].edge_bindings = { [qEdgeID]: [{ id: inferredEdgeID, attributes: [] }] };
322322
if (!combinedResponse.message.knowledge_graph.edges[inferredEdgeID]) {
323323
combinedResponse.message.knowledge_graph.edges[inferredEdgeID] = {
324324
subject: resultCreativeSubjectID,
@@ -357,6 +357,7 @@ export default class InferredQueryHandler {
357357
},
358358
[] as string[],
359359
),
360+
attributes: []
360361
};
361362
}
362363

src/results_assembly/query_results.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,21 @@ export default class TrapiResultsAssembler {
452452
result.node_bindings[inputQNodeID] = Array.from(inputPrimaryCuries).map((inputPrimaryCurie) => {
453453
return {
454454
id: inputPrimaryCurie,
455+
attributes: [],
455456
};
456457
});
457458

458459
result.node_bindings[outputQNodeID] = Array.from(outputPrimaryCuries).map((outputPrimaryCurie) => {
459460
return {
460461
id: outputPrimaryCurie,
462+
attributes: [],
461463
};
462464
});
463465

464466
result.analyses[0].edge_bindings[qEdgeID] = Array.from(recordHashes).map((recordHash) => {
465467
return {
466468
id: recordHash,
469+
attributes: [],
467470
};
468471
});
469472
},

0 commit comments

Comments
 (0)