Rework GraphQL proxy to produce response in the same format as the commercetools API
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3553750. --> Reported by: [murz](https://www.drupal.org/user/157092) Related to !73 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The commercetools GraphQL API returns the data in the "data" object, but our GraphQL proxy returns it in the root object.<br> Because of this, we implemented an "if" condition to handle this on the frontend - <code>modules/commercetools_decoupled/js/libs/commercetoolsApi.js</code>:</p> <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isDirectRequest) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // @todo Rework backend GraphQL proxy to return data in the same<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // format as commercetools GraphQL.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object.assign(result.body, result.body.data);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete result.body.data;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</pre><h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>We need to fix our GraphQL proxy to produce results in the same format as the direct commercetools API responses and remove this "if" condition.</p>
issue