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

[EMBER DATA] record links & meta #332

Merged

Conversation

runspired
Copy link
Contributor

@runspired runspired commented May 11, 2018

@jgwhite
Copy link
Contributor

jgwhite commented May 11, 2018

Great proposal, would be a very welcome addition to ED.

Couple of nice-to-haves:

  • Examples of what one might use meta and links for
  • A code snippet demonstrating how one would rename links/meta in the serializer

Do you think links/meta would also be processed by the serializer to normalize keys?

@runspired runspired added the T-ember-data RFCs that impact the ember-data library label Jun 27, 2018
@sandstrom
Copy link
Contributor

@runspired This would be very useful! 👍

@runspired
Copy link
Contributor Author

@jgwhite

Examples of what one might use meta and links for

meta is very much a grab-bag, but many folks use it to store permissions, expirations, or other information about the resource's data that isn't part of the data itself.

links in the json-api sense are used to fetch and manipulate a resource. Adapters could be made to prefer links when present instead of using buildUrl.

A code snippet demonstrating how one would rename links/meta in the serializer

normalize(modelClass, resource) {
    let { attributes } = resource;
    attributes.attributeMeta = attributes.meta;
    delete attributes.meta;

    attributes.resourceLinks = attributes.links;
    delete attributes.links;

    return this._super(modelClass, resource);
  }

Do you think links/meta would also be processed by the serializer to normalize keys?

Serializers are user-land API space and implementations vary too widely for us to generalize. What is important is that for you to make use of meta and links in this way that you transform them into the correct position as specified by the json-api spec (sibling members to type id attributes and relationships).

There will be no changes to the serializers, so any key munging rules your serializers use would also apply

@runspired
Copy link
Contributor Author

As there have been no further comments, merging.

@runspired runspired merged commit c926bfe into emberjs:master Oct 19, 2018
@runspired runspired deleted the ember-data-record-links-and-meta branch October 19, 2018 02:23
@runspired runspired self-assigned this Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Final Comment Period T-ember-data RFCs that impact the ember-data library
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants