Skip to content

Associate "relationship object" with everything else #946

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

Closed
wants to merge 1 commit into from

Conversation

bintoro
Copy link
Contributor

@bintoro bintoro commented Dec 15, 2015

  • Formally connects relationship objects to relationships and, by extension, to relationships objects.

    The current language effectively doesn't specify what can go inside relationships objects.

    Also, clearly stating the parity between "each relationship" and "an object" hopefully helps emphasize the fact that the section is discussing two different concepts. The distinction between relationships objects and relationship objects is too easy to overlook at first.

  • Edits the sentence that defines members of a relationships object as "relationships". Rather, the members only represent relationships.

  • Fixes a broken link nearby.

object"). Members of the relationships object ("relationships") represent
references from the [resource object][resource objects] in which it's defined to other resource
objects.
object"). Members of the relationships object represent "relationships", i.e.,
Copy link
Member

Choose a reason for hiding this comment

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

While we're here:
...references from the resource objects in which they are defined...

Also, this needs to be updated here too:
https://github.com/json-api/json-api/blob/gh-pages/_format/1.1/index.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wondered about that too. The "it" refers to the relationships object, which is singular. But yes, I agree that it would sound more correct if we referred to the relationships themselves.

@tkellen
Copy link
Member

tkellen commented Dec 15, 2015

👍 from me with those minor nits

@bintoro
Copy link
Contributor Author

bintoro commented Dec 15, 2015

Looks like the author of these rules in normative-statements.json made just the mixup this PR aims to prevent:

    "id": "resource-relationships-object",
    "type": "normative-statements",
    "attributes": {
      "level": "MUST",
      "description": "A \"relationship object\" **MUST** contain [...]
    },

id says "relationships object" but description says "relationship object".

This is my first time dealing with the normative statements file. May an existing id string be edited or will that screw something up?

@bintoro bintoro force-pushed the relationship-object branch from d6b8bf1 to b45098d Compare December 15, 2015 18:59
@tkellen
Copy link
Member

tkellen commented Dec 15, 2015

You can edit the id strings if you like--to my knowledge nobody is using them (yet) :(.

Ideally, we'd mark up our format.md files such that we can generate the normative statement files, but we haven't done so yet. This is to assist with automated testing for the specification. If you have the bandwidth to make this happen, that would be amazing.

@bintoro
Copy link
Contributor Author

bintoro commented Dec 15, 2015

Commit updated. I ended up leaving the id alone for now, since relationships-object can also be read as "item object in section relationships", which leaves the hierarchy intact.


Relationships may be to-one or to-many.

A "relationship object" **MUST** contain at least one of the following:
Each relationship **MUST** be represented by an object (a "relationship object")
Copy link
Member

Choose a reason for hiding this comment

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

So, if we're being nitpicky/precise, my mental model has always been that each relationship has two parts: its name and its contents (the linkage, not the related). So maybe we should say "Each relationship's contents....", or use the prior wording, or make the name + contents division more explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, "each relationship's contents" would seem to make sense.

The prior wording didn't associate relationship objects with any of the other definitions, which prompted the patch in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

One potential problem with "each relationship's contents" is that the relationship object also includes links, and I'm not sure if those are part of the contents???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One way to sidestep the entire issue is to specify that each member of a relationships object must be a relationship object.

It's already mentioned that members of a relationships object represent relationships, so a relationship object's purpose could be defined in terms of either.

@bintoro bintoro force-pushed the relationship-object branch from b45098d to a243917 Compare December 15, 2015 21:35
@bintoro
Copy link
Contributor Author

bintoro commented Dec 16, 2015

@ethanresnick: Looking at this again, I don't think "contents" is a necessary addition, particularly if you feel it's not well defined what makes up the contents.

By necessity, objects consist of key-value pairs, so if a key-value pair represents a relationship, then saying that "a relationship must be represented by an object" makes it very clear that we're referring to the value.

In the Links section there's an exactly similar case:

Each member of a links object is a "link". A link MUST be represented as either: [...]

As for a relationship's contents, there's one existing mention:

[...] a related resource link MUST NOT change because its relationship's content changes.

It does suggest that the content might refer to the set of the referenced resources, although it would be fairly easy (and probably a good idea) to come up with a dedicated term for this, such as a "relationship's target".

@bintoro bintoro force-pushed the relationship-object branch from a243917 to b45098d Compare December 21, 2015 19:25
@tkellen
Copy link
Member

tkellen commented Dec 28, 2015

Just checking in here... is the current round of bike-shedding complete? Are we ready to re-review?

@bintoro
Copy link
Contributor Author

bintoro commented Dec 29, 2015

I'm not sure. The question raised by @ethanresnick was whether it's okay to say

Each relationship MUST be represented by an object [...]

when we actually mean

Each relationship MUST be represented by a member whose value is an object [...]

I'm curious as to what others think. To be sure, the latter is more accurate but perhaps a bit awkward. Another angle is to figure out a term for the value part of a relationship and say

Each relationship's value MUST be represented by an object [...]

@ethanresnick
Copy link
Member

First off, I agree that this PR as written is better than the current text, and it may be good enough. If we want to be totally accurate, though, I think there's a way to separate the definitions of the relationship's name, contents (which isn't a term we need to use necessarily), and "relationship object" without being too awkward.

Here's probably what I'd say (key changes in bold):

The value of the relationships key MUST be an object (a "relationships object"). Each member in the relationships object represents a "relationship", which is a named set of references from the resource object in which it is defined to other resource objects.

Relationships may be to-one or to-many.

A relationship's name is given by its key. The value at that key MUST be an object ("relationship object") that contains the set of referenced resources or information pertaining to that set.

A "relationship object" MUST contain at least one of the following:

....

Thoughts?

@bintoro
Copy link
Contributor Author

bintoro commented Dec 29, 2015

Each member in the relationships object represents a "relationship", which is a named set of references [...]

But isn't this accurate only for to-many relationships? A to-one relationship doesn't feel like a "set of references".

A relationship's name is given by its key.

+1. I think this alone is enough to supplant the "named set" addition.

The value at that key MUST be an object ("relationship object") that contains the set of referenced resources or information pertaining to that set.

A "relationship object" MUST contain at least one of the following: ...

Saying that the object "contains the set of referenced resources" sounds wrong to me; it only contains the references, not the resources. Or is this in preparation for embedded resource objects?

Since the entire bolded segment is basically a summary of what is normatively stated right in the subsequent paragraph, I'd just drop that part entirely:

The value at that key MUST be an object ("relationship object") containing at least one of the following: ...

@ethanresnick
Copy link
Member

But isn't this accurate only for to-many relationships? A to-one relationship doesn't feel like a "set of references".

In my mind, it applies for to-one relationships too (since a set can be limited to one item, which is what I think the next paragraph does), but I see how it could be confusing, so I'm fine with changing it. Ideas?

+1. I think this alone is enough to supplant the "named set" addition.

Ok, but would that mean going back to "[relationships are] references from the resource object in which they are defined to other resource objects". If so, that just sounds a bit weird to me... in my head it's the resource identifier object that's the reference, not the relationship, which is why I'd said the relationship is a set of references.

Saying that the object "contains the set of referenced resources" sounds wrong to me; it only contains the references, not the resources.

Good catch. If we were going to keep it, it should say something like "contains the references that constitute the relationship".

Since the entire bolded segment is basically a summary of what is normatively stated right in the subsequent paragraph, I'd just drop that part entirely:

Works for me. (Though aren't we just back to your original complaint, then, that the definition of a "relationship object" isn't really connected conceptually to what comes before?)

@bintoro
Copy link
Contributor Author

bintoro commented Dec 29, 2015

I love how deep this rabbit hole is going 😄

in my head it's the resource identifier object that's the reference, not the relationship, which is why I'd said the relationship is a set of references.

Aha, this explains a lot. I never considered "reference" with this kind of static meaning in mind.

Thus, I've thought it's perfectly okay to simultaneously say that

  • a relationship is a reference from one resource (object) to another
  • a resource identifier is a reference to a particular resource object

where the first statement implies nothing about the concrete representation or the cardinality of the target.

If we want to narrow the usage of "reference", the first paragraph could say:

Members of the relationships object represent "relationships", i.e., associations between the enclosing resource object and other resource objects.

In fact, "enclosing" might be preferable to "in which they are defined" regardless of the decision w.r.t. "reference".

Though aren't we just back to your original complaint, then, that the definition of a "relationship object" isn't really connected conceptually to what comes before?

No. In the published spec, the definition of relationship object just appears out of nowhere. In the current iteration, we have the statement:

The value at that key MUST be an object ("relationship object") ...

This bridges the gap and is associated with the concept of relationships via the first paragraph that defines relationships object members as relationships.

@ethanresnick
Copy link
Member

I love how deep this rabbit hole is going 😄

Indeed. At least we seem to be getting somewhere 😄 I'll take a look at this with fresh eyes tomorrow.

@bintoro bintoro mentioned this pull request Dec 29, 2015
@ethanresnick
Copy link
Member

Ok, so it sounds like the text you're proposing is:

The value of the relationships key MUST be an object (a "relationships object"). Each member in the relationships object represents a "relationship", i.e., an association between the enclosing resource object and other resource objects.

Relationships may be to-one or to-many.

A relationship's name is given by its key. The value at that key MUST be an object ("relationship object").

A "relationship object" MUST contain at least one of the following:

....

(Or the above, but replacing "Each member..." with "Members...".)

If that's right, then I'm fine with it! Update the PR and we'll get it merged :)

@jelhan
Copy link
Contributor

jelhan commented Feb 6, 2022

Thanks a lot for working on this one. I reviewed it looking at latest state of v1.1. I think that clarification is still needed. I created a follow-up merge request at #1608 to finally get it in. I hope that's okay with everyone who had worked on this before. If you have time, I would appreciate a review of that one to ensure that I understood the consensus reached here correctly.

@dgeb dgeb closed this in #1608 Apr 2, 2022
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