Skip to content

Commit

Permalink
handle empty economicEvent inputOf and outputOf
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed Jul 23, 2024
1 parent e48509f commit d7700f8
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions modules/vf-graphql-holochain/resolvers/economicEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,27 @@ export default (enabledVFModules: VfModule[] = DEFAULT_VF_MODULES, dnaConfig: DN
},
},
(hasProcess ? {
inputOf: async (record: EconomicEvent): Promise<Process> => {
inputOfId: async (record: EconomicEvent): Promise<any> => {
return record.inputOf ? record.inputOf : ""
},
inputOf: async (record: EconomicEvent): Promise<Process | {}> => {
const results = await readProcesses({ params: { observedInputs: record.id } })
return results.edges.pop()!['node']
if (results.edges?.length > 0) {
return results.edges.pop()!['node']
} else {
return {}
}
},

outputOf: async (record: EconomicEvent): Promise<Process> => {
outputOfId: async (record: EconomicEvent): Promise<any> => {
return record.outputOf ? record.outputOf : ""
},
outputOf: async (record: EconomicEvent): Promise<Process | {}> => {
const results = await readProcesses({ params: { observedOutputs: record.id } })
return results.edges.pop()!['node']
if (results.edges?.length > 0) {
return results.edges.pop()!['node']
} else {
return {}
}
},
} : {}),
(hasAgent ? {
Expand Down

0 comments on commit d7700f8

Please sign in to comment.