@dillonkearns/elm-graphql
Version:
<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">
51 lines (39 loc) • 1.22 kB
JavaScript
import _newArrowCheck from 'babel-runtime/helpers/newArrowCheck';
var _this = undefined;
var locationsToString = function (locations) {
_newArrowCheck(this, _this);
return locations.map(function (_ref) {
var column = _ref.column,
line = _ref.line;
_newArrowCheck(this, _this);
return String(line) + ":" + String(column);
}.bind(this)).join("; ");
}.bind(undefined);
var errorToString = function (_ref2) {
var message = _ref2.message,
locations = _ref2.locations;
_newArrowCheck(this, _this);
return message + (locations ? " (" + String(locationsToString(locations)) + ")" : "");
}.bind(undefined);
/**
* Transforms an array of GqlError into a string.
*
* @example
*
* const gqlRespose = {
* errors: [
* {message: "First Error", locations: [{column: 10, line: 2}]},
* {message: "Second Error", locations: [{column: 2, line: 4}]}
* ]
* }
*
* const error = errorsToString(gqlRespose.errors);
* // string with the following:
* // First Error (2:10)
* // Second Error (4:2)
*/
var errorsToString = function (gqlErrors) {
_newArrowCheck(this, _this);
return gqlErrors.map(errorToString).join("\n");
}.bind(undefined);
export default errorsToString;