{"version":3,"file":"utils.mjs","sources":["../../../server/graphql/utils.js"],"sourcesContent":["'use strict';\n\nconst { getOr } = require('lodash/fp');\n\n/**\n * Throws an ApolloError if context body contains a bad request\n * @param contextBody - body of the context object given to the resolver\n * @throws ApolloError if the body is a bad request\n */\nfunction checkBadRequest(contextBody) {\n  const statusCode = getOr(200, 'statusCode', contextBody);\n\n  if (statusCode !== 200) {\n    const errorMessage = getOr('Bad Request', 'error', contextBody);\n\n    const exception = new Error(errorMessage);\n\n    exception.code = statusCode || 400;\n    exception.data = contextBody;\n\n    throw exception;\n  }\n}\n\nmodule.exports = {\n  checkBadRequest,\n};\n"],"names":["getOr","require$$0","checkBadRequest","contextBody","statusCode","errorMessage","exception","Error","code","data","utils"],"mappings":";;;;;;;IAEA,MAAM,EAAEA,KAAK,EAAE,GAAGC,UAAAA;AAElB;;;;KAKA,SAASC,gBAAgBC,WAAW,EAAA;QAClC,MAAMC,UAAAA,GAAaJ,KAAAA,CAAM,GAAA,EAAK,YAAA,EAAcG,WAAAA,CAAAA;AAE5C,QAAA,IAAIC,eAAe,GAAA,EAAK;YACtB,MAAMC,YAAAA,GAAeL,KAAAA,CAAM,aAAA,EAAe,OAAA,EAASG,WAAAA,CAAAA;YAEnD,MAAMG,SAAAA,GAAY,IAAIC,KAAAA,CAAMF,YAAAA,CAAAA;YAE5BC,SAAAA,CAAUE,IAAI,GAAGJ,UAAAA,IAAc,GAAA;AAC/BE,YAAAA,SAAAA,CAAUG,IAAI,GAAGN,WAAAA;YAEjB,MAAMG,SAAAA;AACV,QAAA;AACA,IAAA;IAEAI,KAAAA,GAAiB;AACfR,QAAAA;AACF,KAAA;;;;;;"}