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
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
Comment #6
shubham.prakash commentedThe 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
Comment #7
f.mazeikis commentedReady for review.
Comment #9
wim leersLGTM!
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(-)
Comment #10
wim leersComment #11
wim leersAuto-merge queued — nice :)
Comment #12
wim leers🙈 Fix the issue I meant to link in #9.
Comment #14
wim leers