diff --git a/src/utils/graphql_proxy.ts b/src/utils/graphql_proxy.ts index 12b43c252..d1131b0e8 100644 --- a/src/utils/graphql_proxy.ts +++ b/src/utils/graphql_proxy.ts @@ -24,6 +24,7 @@ export default async function graphqlProxy(userReq: http.IncomingMessage, userRe }); userReq.on('end', async () => { + let status = 200; let reqBodyObject: Record | undefined; try { reqBodyObject = JSON.parse(reqBodyString); @@ -40,7 +41,6 @@ export default async function graphqlProxy(userReq: http.IncomingMessage, userRe const response = await client.query(options); body = response.body; } catch (err) { - let status; switch (err.constructor.name) { case 'MissingRequiredArgument': status = 400; @@ -54,9 +54,9 @@ export default async function graphqlProxy(userReq: http.IncomingMessage, userRe default: status = 500; } - userRes.statusCode = status; body = err.message; } finally { + userRes.statusCode = status; userRes.end(JSON.stringify(body)); } return resolve();