From a9a036ff1a02f0be5e9fe9b667b1bf2ec6a2d2b8 Mon Sep 17 00:00:00 2001 From: nodkz Date: Wed, 19 Aug 2020 19:37:53 +0600 Subject: [PATCH] fix: `formatGraphQLErrors` helper for persisted queries --- .gitignore | 1 + src/createRequestError.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 106193a..9b6781c 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ node_modules /es /lib /node8 +/mjs coverage .nyc_output diff --git a/src/createRequestError.js b/src/createRequestError.js index 999a73e..ea93cc2 100644 --- a/src/createRequestError.js +++ b/src/createRequestError.js @@ -26,13 +26,13 @@ export function formatGraphQLErrors(request: RelayRequest, errors: GraphQLRespon return errors.join('\n'); } + let queryLines = []; const queryString = request.getQueryString(); - if (!queryString) { + if (queryString) { // When using persisted query, queryString is an empty string. - return errors.join('\n'); + queryLines = queryString.split('\n'); } - const queryLines = queryString.split('\n'); return errors .map(({ locations, message }, ii) => { const prefix = `${ii + 1}. `;