Skip to content

Clarify relationship formatting #480

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

Merged
merged 7 commits into from
Mar 26, 2015

Conversation

ethanresnick
Copy link
Member

Update I've edited this description to capture the current state of the PR. It does three things:

  1. When relationship information is being sent to the server as part of a PATCH or POST done on a full resource (as opposed to patching/posting to the relationship directly), the format for sending this information is the same as its representation in GET requests. (I.e. there's a links key with a proper link object.)
  2. This link object containing the new relationship information MUST have a linkage key. This clarifies that relationships can only be set by providing "linkage", not by providing related urls.
  3. It simplifies some of the definitions for PATCHing/DELETEing relationships directly, by introducing the concept of a linkage object. It doesn't go so far as to use link objects to represent single relationships retrieved at/sent to relationship URLs. That discussion is happening here and in Unify formats for representing relationships #482. If that's desired, I can update the PR further.

Ethan added 2 commits March 20, 2015 18:36
Remove trailing spaces; note that the example is an example.
@bintoro
Copy link
Contributor

bintoro commented Mar 21, 2015

Nice job @ethanresnick!

But this PR doesn't go so far as to use link objects to represent single relationships retrieved at relationship URLs.

Whether we want relationship URLs to return the extra layer provided by link objects is one discussion, but in any case I would like to reuse the concept of linkage in that section, too. Makes no sense to talk about "arrays of objects with type and id members" when the format has already been defined elsewhere.

Of course, linkage objects might gain further members that are not applicable to create/update operations, but I don't see a problem with just excluding them as they're defined.

@ethanresnick ethanresnick changed the title Clarify formatting relationships on creation Clarify relationship formatting Mar 22, 2015
@ethanresnick
Copy link
Member Author

Hey guys,

I've updated my original post to describe exactly what this PR now does.

I think there's only one thing left to discuss here... Right now, we only allow the user to set relationship values by providing linkage, rather than, e.g. a related url. While this PR makes that design decision more explicit, I'm wondering if we want to preserve the flexibility for JSON API to become truly hypermedia-based/distributed in the future, which would require the ability to set a resource's value to an arbitrary url.

If we do want to preserve ourselves that option, I think it's as easy as replacing language like "the value MUST be a link object which MUST contain a linkage key" with language like "the value MUST be a link object which SHOULD contain a linkage key. Servers MAY reject attempts to set the value of a relationship when linkage is not provided."

If the resource object being sent contains any relationships in its `"links"`
key, those relationships **MUST** each have a `"linkage"` key that includes the
linkage the new resource is to have.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This phrasing seems awkward. How about keeping it similar to the note below for PATCH:

If a relationship is provided in the links section of a resource object, its value MUST be a link object with a linkage member.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

@hhware
Copy link
Contributor

hhware commented Mar 23, 2015

I'm in favor of the term "linkage object", which seems consistent with "link object" and "resource object".

I am totally fine with linkage objects and have no special feelings for relationship tuples, but I have a small reservation. If one compares linkage object with link object, then the latter is what is keyed by links, whereas one cannot say that linkage object is what is keyed by linkage -- it is wrong in case of to-many relationship. This can be confusing for readers. If this minor thing does not bother anyone else, please ignore it.

Also, I would suggest to extract definition of linkage object into a separate paragraph, not introduce it "on the run":

a "linkage object", which is an object containing...

@ethanresnick
Copy link
Member Author

@hhware

Also, I would suggest to extract definition of linkage object into a separate paragraph, not introduce it "on the run":

I completely agree with this in principle. I only introduced the definition in line for consistency with how the spec currently introduces many of its smaller definitions (e.g. "link object" and "relationship urls" are both defined in parentheticals).

That said, I think the spec would really benefit from having a glossary of terms at the bottom, with every usage of a defined term in the body text linked to its entry in the glossary. If others are onboard with having such a glossary, we could define "linkage object" there.

If one compares linkage object with link object, then the latter is what is keyed by links, whereas one cannot say that linkage object is what is keyed by linkage... If this minor thing does not bother anyone else, please ignore it.

I'll let others chime in about this, but it doesn't particularly bother me.

@bintoro
Copy link
Contributor

bintoro commented Mar 23, 2015

I would suggest to extract definition of linkage object into a separate paragraph

Agreed. Defining the thing as we're explaining to-one relationships doesn't seem right.

I would also like to add a tiny definition for it, similar to what I'm trying to do to linkage here: https://github.com/json-api/json-api/pull/498/files#diff-26e38355b69056b0db1c2b1c612241b2R301

Something like

A "linkage object" identifies an individual related resource. It MUST be represented by an object containing "type" and "id" members.

@ethanresnick
Copy link
Member Author

Ok! I've updated the PR to include the "linkage object" definition in its own paragraph, along the lines @bintoro suggested.

@bintoro
Copy link
Contributor

bintoro commented Mar 23, 2015

I've updated the PR to include the "linkage object" definition in its own paragraph

👍

I think the spec would really benefit from having a glossary of terms at the bottom

Sure, but I'm not crazy about the idea of actually removing definitions from their main context and stashing them only in some appendix.

As I've said elsewhere, I'm planning a big PR that would improve the formatting of primary definitions and add a ton of intra-document links. I just haven't been able to submit it because of the current backlog of conflicting PRs.

Let's re-evaluate the need for an index/glossary after the intra-doc links are in place. As long as stuff is defined in the body text, I view a full glossary as overkill. At most an alphabetical index linking to the primary definitions might be useful.

@ethanresnick
Copy link
Member Author

@bintoro sounds good :)

dgeb added a commit that referenced this pull request Mar 26, 2015
@dgeb dgeb merged commit c0bc63e into json-api:gh-pages Mar 26, 2015
@dgeb
Copy link
Member

dgeb commented Mar 26, 2015

Thanks @ethanresnick et al - merging now. I believe that this removes the last remaining asymmetry in request / response documents. As a bonus, it tightens up the terminology used in the spec with the definition of "linkage object".

@ethanresnick ethanresnick deleted the linkage-for-post branch March 26, 2015 20:19
@ethanresnick
Copy link
Member Author

Great! Thanks @dgeb!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy