Make links and meta available by default in data returned by the preconfigured JsonApiClient
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3570305. -->
Reported by: [wotnak](https://www.drupal.org/user/3558113)
Related to !589 !520
>>>
<h3 id="overview">Overview</h3>
<p>The preconfigured JSON:API client provided in the drupal-canvas package (<code>import { JsonApiClient } from "drupal-canvas";</code>) used for data fetching in code components includes the Jsona serializer. It flattens response data for easier consumption but also omits top level meta and links, whose values are often used for building pagination.</p>
<p>Currently the workarounds are to either create a new manually configured JsonApiClient instance without the Jsona serializer or to pass the rawResponse option, but in both cases we lose nicely flattened, easier to work with response data.</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<p><del>Extend Jsona to decorate deserialized data with non enumerable getMeta() and getLinks() methods that will return top-level meta and links. This way top level meta and links will be accessible in the same way on collections and single resources (which can have their own resource level meta and links), and we will maintain backward compatibility with existing usage of deserialized data (for example code fetching a collection and iterating over the results will work the same since the methods won't be enumerable).</del></p>
<p>Extended jsona serializer with getMeta() and getLinks() methods will be added upstream in the API Client <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/api_client/issues/3426518" title="Status: Closed (fixed)">#3426518: Using Serializer Obscures Links and Pagination Data</a></span>.</p>
<p>After it is merged and released:</p>
<ul>
<li>update the <a href="https://git.drupalcode.org/project/canvas/-/blob/eeb585bb2e78de2f4d4ec6977629a30e35f8d0f0/packages/drupal-canvas/src/jsonapi-client.ts#L31">preconfigured JSON API client</a> provided in the drupal-canvas package to use the new default serializer from API Client instead of jsona directly,</li>
<li>update <a href="https://git.drupalcode.org/project/canvas/-/blob/eeb585bb2e78de2f4d4ec6977629a30e35f8d0f0/docs/user/src/content/docs/code-components/data-fetching.mdx#L120">user docs on data fetching</a>.</li>
</ul>
> Related issue: [Issue #3426518](https://www.drupal.org/node/3426518)
issue