NJsonApiCore icon indicating copy to clipboard operation
NJsonApiCore copied to clipboard

Spec deviation: POST relationships not available in Delta<MyResource>

Open brainwipe opened this issue 9 years ago • 1 comments

As per the spec:

If a relationship is provided in the relationships member of the resource object, its value MUST be a relationship object with a data member. The value of this key represents the linkage the new resource is to have.

When inside a POST controller such as: [Route] [HttpPost] public IHttpActionResult Post([FromBody]Delta<MyResource> resourceDelta) {

There is no way to get at the relationships, they are ignored. The UpdateDocument class must include the relationships and in turn they should be accessible through the Delta<>. These are just links, the system should not attempt to automatically load them, it is should assumed that the API implementer knows what to do with these links.

brainwipe avatar Aug 29 '16 14:08 brainwipe

The not-very-good way around this is to pass the Id of the linked object as another attribute. This would mean that POST and GET would be different and not in the spirit of the json:api but is a workaround until this feature can be implemented.

brainwipe avatar Aug 29 '16 14:08 brainwipe