-
-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Is your feature request related to a problem? Please describe.
Currently, ZenStack's automatic REST API handles single-resource creation effectively. However, when building complex frontends (especially those using JSON:API standards), there is often a need to create a primary entity along with several related "child" entities in a single atomic HTTP request.
Without support for Local IDs (lid) and the included section for writable operations, developers must:
- Issue multiple sequential requests.
- Manage temporary client-side IDs.
- Handle partial failures (where the parent is created but children fail), which complicates transaction management on the frontend.
Describe the solution you'd like
I would like the ZenStack REST API to support "side-posting" by recognizing the lid (Local ID) and included attributes during a POST request. This would allow a single request to create a resource and its related resources simultaneously by linking them via a temporary local identifier.
Key Requirements:
- LID Support: Support
lidas a temporary identifier within therelationshipsandincludedblocks to link resources that don't have a server-generated ID yet. - Side-posting in
included: The API should parse theincludedarray in aPOSTrequest and treat those objects as resources to be created alongside the primary data. - Atomic Operations (Next Step): Ideally, this should pave the way for full support of the JSON:API Atomic Operations extension, allowing multiple independent operations in one transaction.
Example Payload:
{
"data": {
"type": "articles",
"attributes": { "title": "New Article" },
"relationships": {
"author": { "data": { "type": "people", "lid": "temp-author-1" } }
}
},
"included": [
{
"type": "people",
"lid": "temp-author-1",
"attributes": { "name": "Jane Doe" }
}
]
}