Skip to content
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

make "meta included false" on relationships optional? #109

Closed
nruth opened this issue Sep 9, 2018 · 5 comments
Closed

make "meta included false" on relationships optional? #109

nruth opened this issue Sep 9, 2018 · 5 comments

Comments

@nruth
Copy link

nruth commented Sep 9, 2018

like in #90

This causes issues with some client libraries (throwing away previously loaded relationship data), and generally seems unnecessary. Is there a compelling reason for this being on by default and having no way to turn it off?

@beauby
Copy link
Member

beauby commented Apr 5, 2019

The reason is that the spec states:

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

  • links: a links object containing at least one of the following:
    [...]
  • data: resource linkage
  • meta: a meta object that contains non-standard meta-information about the relationship.

If you do provide a link definition for your relationship, the meta: { included: false} will disappear. However, if there is neither a data member, nor a links member, the spec forces us to have a meta member.

@beauby beauby closed this as completed Apr 5, 2019
@nruth
Copy link
Author

nruth commented Apr 5, 2019

I see something different in the spec. If you scroll up to https://jsonapi.org/format/#document-resource-objects (screenshot attached) it says saying you must include id and type but everything else is optional. So the relationships key can be omitted entirely, meaning you can skip this bit about links/data/meta.

Screenshot 2019-04-05 at 17 33 13

From looking at "MAY" in https://tools.ietf.org/html/rfc2119 what you're doing is perhaps fine, but it still seems unnecessary and is breaking ember-data and I think led me to post-process the json to delete those keys.

@beauby
Copy link
Member

beauby commented Apr 5, 2019

it says saying you must include id and type but everything else is optional. So the relationships key can be omitted entirely, meaning you can skip this bit about links/data/meta.

That would make for a valid payload in general, but not for a valid response unless the relationship in question was explicitly discarded via sparse fieldsets.

@nruth
Copy link
Author

nruth commented Apr 5, 2019

Valid according to what? Could you point that out in the spec?

@Diasporism
Copy link

Yeah I have to side with @nruth on this one. The relationships node is optional and JSON API spec never requires it unless a client asks for an associated record via the include param.

I'm not against it always existing, but the way it's implemented in this library is actually broken and causing bugs. I've opened a related issue here and a PR to fix it by just removing it altogether. My reasonings are explained in the other issue and I'm open for debate over there.

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

No branches or pull requests

3 participants