-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More consistent resource linkage. #447
Conversation
In favor 👍 A further benefit not mentioned in @dgeb's comment is that this eliminates the need to maintain a separate format for relationship URL representations. |
👍 here too. |
Resource linkage is consistently represented in a `linkage` member within each link object. This simplifies the rules for resource linkage across homogeneous and heterogeneous relationships.
1fc1a0c
to
3f56347
Compare
👍 from me too |
IMHO, a great improvement! |
Also in favor. |
It should have been this way from the start if you wanted to support heterogeneous relationships. +1 |
I think the trade-off in verbosity is fine if it means better consistency. This also might make it easier to write a client-side caching that looks up by a key based on 🚀 |
With all in favor and no objections, I'm merging. |
More consistent resource linkage.
:+1 This is indeed more consistent and gets rid of the ugly 'data' member in resource relationsships.
|
+1 on this too! |
@dgeb The only time the word "heterogeneous" is mentioned in the spec is a non-normative note. I think it would be useful to provide at least some examples for it, to make it clearer why the resource type needs to be specified twice, in the URL / linkage name and inside the linkage itself. E.g., examples could be provided for creating and updating heterogeneous relationships. Would there be any intetrest in such examples, or they were omitted intentionally? |
Ref: json-api/json-api#447 Seems like this PR (linkedRenaming) is an appropriate place to include this.
I put together this PR as the result of a discussion in #437. As I mentioned, this was one approach that I considered while working on RC2, but was concerned with the verbosity.
However, after discussing with a couple implementors who are in favor of these simplifications, I'd like to put this out there for general consideration. Even though this is the 11th hour for the spec, it's probably worthwhile to consider a simplifying approach.
The gist is that resource linkage is consistently represented in this approach, regardless of whether relationships are homogeneous or heterogeneous. Linkage is contained within a
linkage
member in the links object, eliminating the dichotomy of using eithertype
/id
(for homogeneous relationships) vs.data
(for heteregeneous relationships).Here's the home page resource object currently:
And here it is after this change:
I find this structure to be more consistent with resource objects themselves, which all must contain a
type
andid
. This approach also simplifies endpoints for updating relationships.But of course, as I've said, it is more verbose.