diff --git a/firebase-vscode/CHANGELOG.md b/firebase-vscode/CHANGELOG.md index bba4147551c..43419d6ea0d 100644 --- a/firebase-vscode/CHANGELOG.md +++ b/firebase-vscode/CHANGELOG.md @@ -1,5 +1,7 @@ ## NEXT +- [Fixed] Fixed a bug where results panel would break on API error + ## 0.12.1 - Updated internal `firebase-tools` dependency to 13.29.2 diff --git a/firebase-vscode/webviews/data-connect/DataConnectExecutionResultsApp.tsx b/firebase-vscode/webviews/data-connect/DataConnectExecutionResultsApp.tsx index d44a8565926..96a1e16eb1a 100644 --- a/firebase-vscode/webviews/data-connect/DataConnectExecutionResultsApp.tsx +++ b/firebase-vscode/webviews/data-connect/DataConnectExecutionResultsApp.tsx @@ -31,14 +31,11 @@ export function DataConnectExecutionResultsApp() { // in case the user wants to see the response anyway. response = results.data; const errors = results.errors; - if (errors && errors.length !== 0) { errorsDisplay = ( <> - {errors.map((error) => ( - - ))} + ); } @@ -106,27 +103,40 @@ function InternalErrorView({ error }: { error: SerializedError }) { } /** A view for when an execution returns status 200 but contains errors. */ -function GraphQLErrorView({ error }: { error: GraphQLError }) { +function GraphQLErrorView({ errors }: { errors: readonly GraphQLError[] }) { let pathDisplay: JSX.Element | undefined; - if (error.path) { - // Renders the path as a series of kbd elements separated by commas - pathDisplay = ( - <> - {error.path?.map((path, index) => { - const item = {path}; + // update path + const errorsWithPathDisplay = errors.map((error) => { + if (error.path) { + // Renders the path as a series of kbd elements separated by commas + return { + ...error, + pathDisplay: ( + <> + {error.path?.map((path, index) => { + const item = {path}; - return index === 0 ? item : <>, {item}; - })}{" "} - - ); - } + return index === 0 ? item : <>, {item}; + })}{" "} + + ), + }; + } + return error; + }); return ( -

- {pathDisplay} - {error.message} - {error.stack && } -

+ <> + {errorsWithPathDisplay.map((error) => { + return ( +

+ {pathDisplay} + {error.message} + {error.stack && } +

+ ); + })} + ); }