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

store._push ignores meta data for single record responses #5363

Closed
mattmarcum opened this issue Feb 24, 2018 · 4 comments
Closed

store._push ignores meta data for single record responses #5363

mattmarcum opened this issue Feb 24, 2018 · 4 comments

Comments

@mattmarcum
Copy link

mattmarcum commented Feb 24, 2018

The json-api spec says that meta can be present on a resource object, so I took advantage of that to return some additional data there in my api.

It took me awhile to figure out why my meta hash for a single record response wasn't available anywhere. The JSONAPISerializer hooks all showed that the meta key was present. It wasn't until I stepped into the code and got into store.push and store._push that I realized this was were the meta hash was getting ignored.

store._push takes one argument jsonApiDoc and the only member that's ever accessed off of it is data. Looks like this code passes jsonApiDoc.data off to store._pushInternalModel so I don't think the fix would be trivial.

I sort of got around this by creating a meta attr on my model and then moving the meta hash to data.attributes.meta during the normalizeSingleRecord hook in the model's serializer.

I'm guessing this is all going to be affected by the model-data rfc, so I guess I'm just wondering if anyone else has run into this problem and has a better fix.

@mattmarcum
Copy link
Author

mattmarcum commented Feb 24, 2018

Just fyi, I tried putting meta as both a top-level member { data: {...}, meta: {...}} and as a member of data: { data: {..., meta: {...}}. Both options seem valid according to the json-api spec.

@runspired
Copy link
Contributor

We sadly don't have a good story around meta links and errors today at the resource, relationship or document level. This is something we will be addressing this year.

@runspired
Copy link
Contributor

Closing in favor of the quest ticket for this: #2905

@runspired
Copy link
Contributor

@mattmarcum I thought you'd like to know that the RFC is up :)

emberjs/rfcs#332

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

2 participants