Repository navigation
Subrequests - #68
Subrequests#68
Conversation
6e07cde to
cd73a03
Compare
447e100 to
24aacad
Compare
Namely: farmOS.js/src/client/subrequest.js Lines 184 to 202 in d1d4ee3 @mstenta or @paul121, any guess why a POST request to a an entity's relationship endpoint returns a Here's the example I tested locally, with a preexisting input log and quantity: farmOS.js/test/client/relationships.js Lines 19 to 25 in d1d4ee3 Here's the relevant JSON:API spec: |
|
Log quantities are a bit unique because they have a revision ID as well. When you update an existing quantity then the log needs to be updated to that new revision as well. I haven't tried creating or updating log quantities via the relationship endpoint so there might be some gotchas there. Some python code I have where I first create a quantity entity and then create/update a log in a second request. This is the part that specifies the quantity relationship & quantity revision ID: # Add quantity to log.
log["relationships"]["quantity"] = {
"data": [
{
"type": "quantity--standard",
"id": harvest_quantity["data"]["id"],
"meta": {
"target_revision_id": harvest_quantity["data"]["attributes"]["drupal_internal__revision_id"]
}
},
]
}Maybe this would work, assuming a const uri = '/api/log/input/f9f44a71-4373-4a60-ac36-37f5564b86e8/relationships/quantity';
const quantity = {
id: '9fb2963d-7185-4da7-9ccd-d6e29e0f22c1',
type: 'quantity--standard',
meta: {
target_revision_id: quantityRevisionId,
},
};
const data = JSON.stringify({ data: [quantity] });
return farm.remote.request(uri, { method: 'POST', data }); |
24aacad to
74dc944
Compare
|
Oh that sounds like a good lead! Thanks, @paul121, I will try that out tomorrow. |
This still has some issues, but I couldn't help committing some changes to the overall project structure along the way, which I'm too lazy to try and disentangle, so I just added some warnings instead.
This branches off #67 and should be merged subsequently.