Ignore included resources without that don't have a corresponding ember-data model - #5178
Merged
bmac merged 1 commit intoSep 28, 2017
Conversation
lukemelia
force-pushed
the
ignore-unknown-jsonapi-resource-types
branch
from
September 16, 2017 00:24
bcc542d to
de744e0
Compare
runspired
requested changes
Sep 16, 2017
| ret[i] = normalized; | ||
| } | ||
| if (needsCompacting) { | ||
| ret = ret.filter(Boolean); |
Contributor
There was a problem hiding this comment.
I think we should just use push and an explicit check for not null vs preallocating length here.
Contributor
Author
There was a problem hiding this comment.
Sounds good @runspired. I was concerned about changing the performance characteristics of the happy path, but I agree that is clearer. I'll make the change now.
…responding ember-data model When the JSON API serializer encounters a resource with a type that doesn't resolve to one of the application's Ember Data models, it replaces the object with `null` and emits a warning. Prior to this commit, if that `null` was one of the sideloaded (i.e. `included`) resources, the store would throw trying to get the `null`'s type. This commit makes the serializer drops any nulls out of the list of included resources to avoid this problem. To summarize, if your API attempts to include resources that you don't have models for, a warning will be emitted and they will be ignored. Fixes warp-drive-data#4568
lukemelia
force-pushed
the
ignore-unknown-jsonapi-resource-types
branch
from
September 16, 2017 21:01
de744e0 to
056a1c9
Compare
Contributor
|
Thanks @lukemelia. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the JSON API serializer encounters a resource with a type that doesn't resolve
to one of the application's Ember Data models, it replaces the object with
nullandemits a warning. Prior to this commit, if that
nullwas one of the sideloaded(i.e.
included) resources, the store would throw trying to ask for thenull's type.This commit makes the serializer drop any nulls out of the list of included resources
to avoid this problem.
To summarize, if your API attempts to include resources that you don't have models for,
a warning will be emitted and they will be ignored.
Fixes #4568