data
data copied to clipboard
Finder should not inspect adapter's payload too closely
I've run into a slight problem with Ember data.
My use case:
- For business reasons, my backend needs to talk XML. Luckily, I get to define the XML response myself, so I'm working with somewhat sane documents.
- I've written an Ember data serializer that consumes parsed XML documents (instances of
XMLDocument
) and emits proper JSONAPI compliant JavaScript objects for the Ember data store.
The problem:
-
payloadIsNotBlank()
at /addon/-private/system/store/finders.js#L19 counts the object's keys. - On Internet Explorer 11, the
XMLDocument
instance has no own, enumerable properties, hence the assertion fails.
Obviously, this is easy to circumvent: I've avoided the overzealous assertion by wrapping the XML document in an array and unwrapping it in my deserializer.
But still, I would argue that it is not the _find
method's job to check the adapter's result. This should be left entirely to the serializer. At most, it could check if the adapter's result is of type undefined
or equal null
, but for any other value, it should be assumed that a sufficiently clever serializer will be able to interpret the value in a meaningful way or throw a sensible error message.
Broadly speaking I agree and have always found this frustrating.
This is handled by https://github.com/emberjs/rfcs/pull/860, closing in favor