-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
JSONAPI store.normalize doesn't accept "data:{}" format #4285
Comments
There was a PR which introduced Can you outline the use case for which you would need a method, which normalizes the payload but does not push it into the store? |
That is a fair question - I don't have an answer. This mainly stem because my back-end always wraps things with
And adds the example that I missed all along (that you have to extract |
@wecc what are your thoughts on the idea of making normalize smart enough to unwrap the object from if its nested under a |
FYI, RFC#161 proposes to have a public |
Given the ease of composing a few store methods to properly normalize data with better context than As an example: const modelName = 'user';
const ModelClass = store.modelFor(modelName);
const serializer = store.serializerFor(modelName);
const normalized = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query'); |
I thought there was a bug in normalize, but @wecc pointed to me that store.normalize expects its payload to not be wrapped in a
data:{...}
block. Passing it a JSONAPI server's response directly results in a weird exception when trying to deCamelize.I believe there should either be a warning when the data seems not-correctly structured, or since the usefulness of being able to pass an unmodified server response directly to normalize (and then to
store.push
), it should be able to handle both cases.I am aware of the
pushPayload
(and the relevant feature flag in 2.5 to return values from it) but it would be nice if this worked too.Original (now working) Twiddle here: https://ember-twiddle.com/f57e4bff221997a87f51?openFiles=templates.application.hbs%2C
The text was updated successfully, but these errors were encountered: