-
Notifications
You must be signed in to change notification settings - Fork 40
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
Mixed data and meta #9
Comments
Hi @apsavin, Yes, you are correct. I would say it was designed in this way because of "historical reasons". In the beginning, there was no As for now, I would leave it as it is before I don't accumulate more breaking changes. |
I think, it's possible to fix this behavior without a breaking change using an extra option.
We can even log a warning message that I can send a PR. Thoughts? |
Sounds good to me. |
What do you think about to split it in two independent functions (eg: |
Maybe we could leave |
Well, sounds ok to me, but usually programmer wants just put result of a request in and get normalized data out. Why do two calls instead of one? |
Was anyone here successful in parsing meta data with a different package? Had been happily using this package but unfortunately we require meta data now. Going through the client-side packages, any recommendations would be great! Thanks |
@NathanCH Meta should be also available. Please create a separate issue and provide your BE response and what you are getting after |
I'm not totally sure of my work yet, but as I previously used import nativeNormalize from "json-api-normalizer" // https://github.com/yury-dymov/json-api-normalizer
const normalize = (json, opts = {}) => {
const entities = nativeNormalize(json, opts)
const result = json.data.map(({ id }) => id)
const meta = json.meta
return { entities, result, meta }
}
export default normalize Not perfect but works in my case for the moment. |
@kud this looks great :) Might be helpful for some other folks |
Thanks. We're moving from HAL to JSON:API. It sounds to be more flexible and easier for me as frontend dev to ask the data. Plus I don't need to create any schema, it's already done by json:api convention/son-api-normalizer. Loving it! |
It seems that
json-api-normalizer
can't work if I have an entity with typemeta
. Am I right?Why not use
entities
andresult
top-level keys, like originalnormalizr
does?The text was updated successfully, but these errors were encountered: