Hi,
I am working on a project which extensively uses JSON:API specifications.
The client requests a compound document using the include keyword.
The server successfully responds with a valid compound document having “full linkage”.
The “relationships object” contains “relationship object” for all the direct relationships for the document’s primary data.
Each “relationship object” only contains the data section, i.e. Resource Linkage.
The client makes the same request multiple times (polling) to stay updated with the state of the data on the server.
The relationships that the primary data has at any give point might change depending upon the state of the resource.
If the primary data has a relationship, it is present in the server response as a “relationship object” having Resource Linkage.
If the primary data does not have a relationship, that “relationship object” itself is absent from the “relationships object”.
It can happen that the response from server contained a specific “relationship object” at a specific time, and did not contain that “relationship object” at a later time.
Now, the client (using Ember) is unable to process the removal of this “relationship object” and continues to show the stale relationship.
Client is of the opinion that the server should have sent a “relationship object” (with null/empty-array Resource Linkage) for the absent relationship(s), quoting:
Resource linkage MUST be represented as one of the following:
- null for empty to-one relationships.
- an empty array () for empty to-many relationships.
- a single resource identifier object for non-empty to-one relationships.
- an array of resource identifier objects for non-empty to-many relationships.
We require clarity on the interpretation of the above.
I think the above text implies that if a resource linkage is present in the “relationship object”, it must be represented in one of the above specified ways.
It does not however anyhow imply that a null/empty-array Resource Linkage is a must for non-existent relationship(s).
Also, going through the below sections, I don’t find any statement implying that “relationship object” (with null/empty-array Resource Linkage) is mandatory for non-existent relationship(s):
The compound object returned from the server always conforms to the “full linkage” specification.
Does JSOP:API require the “relationships object” to mandatorily contain “relationship object” (with null/empty-array Resource Linkage) for non-existent relationship(s)?