diff --git a/src/utils/graphqlClient.js b/src/utils/graphqlClient.js index 7fd28adda..d534b0e44 100644 --- a/src/utils/graphqlClient.js +++ b/src/utils/graphqlClient.js @@ -3,12 +3,20 @@ import fetchUtil from './fetchUtil'; const fetch = fetchUtil('/graphql'); +const minifyQuery = query => + query + .replace(/\s?([{}()])\s?/g, '$1') + .replace(/\s+/g, ' ') + .trim(); + const graphqlClient = ({ variables, query, options, token }) => - fetch.post({ body: { query, variables }, token, options }).then(response => { - if (response.errors) { - throw new GraphqlError(response.errors); - } - return response.data; - }); + fetch + .post({ body: { query: minifyQuery(query), variables }, token, options }) + .then(response => { + if (response.errors) { + throw new GraphqlError(response.errors); + } + return response.data; + }); export default graphqlClient;