Skip to content

Commit d7700f8

Browse files
committed
handle empty economicEvent inputOf and outputOf
1 parent e48509f commit d7700f8

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

modules/vf-graphql-holochain/resolvers/economicEvent.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,27 @@ export default (enabledVFModules: VfModule[] = DEFAULT_VF_MODULES, dnaConfig: DN
8181
},
8282
},
8383
(hasProcess ? {
84-
inputOf: async (record: EconomicEvent): Promise<Process> => {
84+
inputOfId: async (record: EconomicEvent): Promise<any> => {
85+
return record.inputOf ? record.inputOf : ""
86+
},
87+
inputOf: async (record: EconomicEvent): Promise<Process | {}> => {
8588
const results = await readProcesses({ params: { observedInputs: record.id } })
86-
return results.edges.pop()!['node']
89+
if (results.edges?.length > 0) {
90+
return results.edges.pop()!['node']
91+
} else {
92+
return {}
93+
}
8794
},
88-
89-
outputOf: async (record: EconomicEvent): Promise<Process> => {
95+
outputOfId: async (record: EconomicEvent): Promise<any> => {
96+
return record.outputOf ? record.outputOf : ""
97+
},
98+
outputOf: async (record: EconomicEvent): Promise<Process | {}> => {
9099
const results = await readProcesses({ params: { observedOutputs: record.id } })
91-
return results.edges.pop()!['node']
100+
if (results.edges?.length > 0) {
101+
return results.edges.pop()!['node']
102+
} else {
103+
return {}
104+
}
92105
},
93106
} : {}),
94107
(hasAgent ? {

0 commit comments

Comments
 (0)