Open Thiryn opened 6 years ago
@Thiryn
Rule you quoted applies only for resource objects, not the pointer objects inside relationships
payload.
So I think creating an object and relationship in one request is not supported by JSON:API because you need to set id
and type
for relationship element. Please correct me if I'm wrong.
I think there are drafts about creating nested object here. But even without talking about creating the resource on server-side, for now it is not possible to create resources such as car
on client-side with Vox.
My use-case is a resource with relations (like car
), with a client-side creation of temporary related object (temporary tires
) that are not going to be persisted on server-side but used on the application.
@Thiryn You are right. I will find a solution and implement it in a couple of days. Stay tuned. Thanks for reporting.
The ResourcePool store resources, with a key that use
id
andtype
So, any Resource without an
id
can not be stores. Problem is, when you want to create object and relation on client-side, it fails. From the JSONAPI :Such a Thing would not work :
I would suggest to add a default
id
to a resource in ResourcePool::addResource if none is given by the user :