Overview

Currently auto-saves/pending endpoint returns auto-save entries as a collection of objects:

{
  'entry_key:1' : {entry_1}, 
  'entry_key:2' : {entry_2}
}

This worked fine until now, but going forward we should stick closer to JSON:API response structure, specifically the document top level format. Specifically, we should encapsulate the entries in data property on HTTP 200 responses:

{
 'data' : {
   'entry_key:1' : {entry_1}, 
   'entry_key:2' : {entry_2}
 }
}

Doing this will allow us to return HTTP 409 errors as well as data when we will be adding an ability to recover from some of the HTTP 409 responses using Canvas UI without forcing page refresh as part of [#3587587]

Proposed resolution

Modify the controller, tests and openapi response definition for auto-saves/pending HTTP 200 response to be encapsulated in a data property at the top level.

User interface changes

Minor change in React code to support new response structure, no changes that affect end-user.

Issue fork canvas-3588038

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

f.mazeikis created an issue. See original summary.

f.mazeikis changed the visibility of the branch 3588038-refactor-auto-save-endpoint to hidden.

f.mazeikis changed the visibility of the branch 3588038-refactor-auto-save-endpoint to active.

shubham.prakash made their first commit to this issue’s fork.

shubham.prakash’s picture

The endpoint wraps entries in a top-level `data` property.

The transformResponse extracts response.data before RTK Query caches the result, so all the existing updateQueryData calls in publishAllPendingChanges and discardPendingChange continue to work against the flat PendingChanges shape without any further changes.

Note: AI Assisted Code

f.mazeikis’s picture

Assigned: f.mazeikis » wim leers
Status: Active » Needs review

Ready for review.

wim leers made their first commit to this issue’s fork.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community
Related issues: +#3588038: Refactor auto-save endpoint response to encapsulate entries in top-level "data" key, like JSON:API, to enable adding errors later

LGTM!

Pushed commits to minimize changes (i.e. avoid mass renames that were applied only in some places).

Before: 9 files changed, 119 insertions(+), 97 deletions(-)
After: 9 files changed, 84 insertions(+), 66 deletions(-)

wim leers’s picture

Title: Refactor auto-save endpoint response to encapsulate entries in "data" » Refactor auto-save endpoint response to encapsulate entries in top-level "data" key, like JSON:API, to enable adding errors later
wim leers’s picture

Priority: Major » Normal
Issue tags: +blocker

Auto-merge queued — nice :)

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.