-
-
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
pre-rfc: deprecate store.pushPayload and store.serializeRecord #8815
Comments
That probably requires a little bit more of explanation, here is a use-case that I have: I use pushPayload a lot, as I do interact with API through simple requests, get JSON API in return, and push to ember-data when I know that I will work with those records. As I see it, ember-data should be aware of how to hydrate supported format (json-api) into the models. It just fills weird, that for sort-of standard operations, something custom is required. Serializers are part of the ember-data, as well as JSON API format itself. Can we get a little bit of context, why this 4 lines for pushPayload can't stay in ember-data? |
This is exactly how
If you are already in
It isn't 4 lines. It's much more once you consider the corresponding serializer code and a terrible amount more still once you consider that app engineers must align their payloads to a hidden, highly inefficient, non-json-api format for the method to even work. Furthermore, an unfortunate design mistake means that for most applications, the corresponding serializer hook has zero context on the payload being normalized (it does not receive the |
Can this be added to the RFC? What's this unfortunate design mistake? Why is it important for the serializer hook to have context around the payload being normalized? |
Considering my own confusion around these two methods, as well as watching the comments around this stuff recently, I would propose updating docs to make it clearer that Currently, the docs section titled Store createRecord() vs. push() vs. pushPayload() reads:
Nowhere does either paragraph mention |
@runspired I've been trying to convert our It seems that When you have an application that uses the I guess that json-api spec is "agnostic about inflection rules"... which implies both singularized & pluralized type strings should work with |
I was playing around on ember-twiddle and for the life of me I can't figure out why the serialized representation is different in |
@sdhull feel free to ping me on slack or discord to avoid sidetracking the conversation here; however, the short answer to your troubles is that One of the downsides of the existing serializer implementation is that folks have never come to realize the criteria for what the store actually needs, resulting in folks aligning to the serializer spec instead of the store spec. Folks using json-api shouldn't require a normalization method at all if aligned, but unfortunately they haven't known what to align to. That said, even for the simple case of fixing types, authoring your own serializer is often cleaner and many orders of magnitude more maintainable and performant. I left a comment with a demo of this here: #4110 (comment) |
|
I'm closing this due to inactivity. This doesn't mean that the idea present here is invalid, but that, unfortunately, nobody has taken the effort to spearhead it and bring it to completion. Please feel free to advocate for it if you believe that this is still worth pursuing. Thanks! |
we're still planning on tackling this |
flushed out the description of the RFC to be tackled |
handled by emberjs/rfcs#964 |
Similar to #8873,
The RequestManager paradigm is simply that any request starts by providing FetchOptions. These may be built programmatically (for instance for relationships or collections that return links information from the API), or by builders or even manually.
Users have the choice of providing the body for a request at the point of the request, or inserting one later using a request handler. For both cases, EmberData provides access to the
cache
and its APIs for diffing state changes, as well asserializePatch
andserializeResources
utils for each cache implementation that we ship.The legacy pattern's inflexibility meant that users often needed to eject from using adapter/serializer paradigms to fetch data. The new paradigm does not have these constraints, so we wish to deprecate the following methods that served only as work around and only work with these legacy primitives:
store.pushPayload
store.serializeRecord
What to do instead
For Modern Apps
store.push
to upsertstore.push
to upsertRequestManager
now that the limitations of the adapter pattern are goneFor Apps still using Legacy
store.serializerFor
andserializer.normalizeResponse
to normalize payloads before usingstore.push
.pushPayload
to return a value. #4110 (comment)The text was updated successfully, but these errors were encountered: