src/ReindexRelayNetworkLayer.js
function formatRequestErrors(request, errors) {
  const CONTEXT_BEFORE = 20;
  const CONTEXT_LENGTH = 60;

  const queryLines = request.getQueryString().split('\n');
  return errors.map(({locations = [], message}, ii) => {
    const prefix = (ii + 1) + '. ';
    const indent = ' '.repeat(prefix.length);
    return (
      prefix + message + '\n' +
      locations.map(({column, line}) => {
        const queryLine = queryLines[line - 1];
        const offset = Math.min(column - 1, CONTEXT_BEFORE);
        return [
          queryLine.substr(column - 1 - offset, CONTEXT_LENGTH),
          ' '.repeat(offset) + '^^^',
        ].map(messageLine => indent + messageLine).join('\n');
      }).join('\n')
    );
  }).join('\n');
}
function formatRequestErrors(request, errors) {
  const CONTEXT_BEFORE = 20;
  const CONTEXT_LENGTH = 60;

  const queryLines = request.getQueryString().split('\n');
  return errors.map(({locations = [], message}, ii) => {
    const prefix = (ii + 1) + '. ';
    const indent = ' '.repeat(prefix.length);
    return (
      prefix + message + '\n' +
      locations.map(({column, line}) => {
        const queryLine = queryLines[line - 1];
        const offset = Math.min(column - 1, CONTEXT_BEFORE);
        return [
          queryLine.substr(column - 1 - offset, CONTEXT_LENGTH),
          ' '.repeat(offset) + '^^^',
        ].map(messageLine => indent + messageLine).join('\n');
      }).join('\n')
    );
  }).join('\n');
}
function formatRequestErrors ( request , errors ) { const CONTEXT_BEFORE = 20 ; const CONTEXT_LENGTH = 60 ; const queryLines = request . getQueryString ( ) . split ( '\n' ) ; return errors . map ( ( { locations = [ ] , message } , ii ) => { const prefix = ( ii + 1 ) + '. ' ; const indent = ' ' . repeat ( prefix . length ) ; return ( prefix + message + '\n' + locations . map ( ( { column , line } ) => { const queryLine = queryLines [ line - 1 ] ; const offset = Math . min ( column - 1 , CONTEXT_BEFORE ) ; return [ queryLine . substr ( column - 1 - offset , CONTEXT_LENGTH ) , ' ' . repeat ( offset ) + '^^^' , ] . map ( messageLine => indent + messageLine ) . join ( '\n' ) ; } ) . join ( '\n' ) ) ; } ) . join ( '\n' ) ; }
Formats an error response from GraphQL server request.
Formats an error response from GraphQL server request .