Skip to content

Commit

Permalink
Added guard where vocabulary terms was an empty lists, causing the fo…
Browse files Browse the repository at this point in the history
…rm to crash
  • Loading branch information
zachsa committed Jul 29, 2021
1 parent a0dfddd commit f71096c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import logSql from '../../../lib/log-sql.js'
export default async (_, { root, roots, tree }, ctx) => {
const { query } = ctx.mssql

if (!root && !roots?.length) {
if (!root && !roots) {
throw new Error('Either a vocabulary "root" or "roots" argument must be provided')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export default ({
}

if (gqlError) {
throw gqlError
throw new Error(
`GQL Error in Vocabulary select (multiple roots) form component. ${gqlError.message}`
)
}

let options
Expand All @@ -85,6 +87,10 @@ export default ({
}
}

if (!options.length) {
return null
}

return (
<Multiselect
id={id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default ({
}

if (gqlError) {
throw gqlError
throw new Error(`GQL Error in Vocabulary select form component. ${gqlError.message}`)
}

/**
Expand Down

0 comments on commit f71096c

Please sign in to comment.