-
-
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
[DOC] Improve warning for mismatched id in store.findRecord #4609
[DOC] Improve warning for mismatched id in store.findRecord #4609
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for removing the javascript
type for comment
@@ -1223,8 +1224,7 @@ Store = Service.extend({ | |||
|
|||
The request is made through the adapters' `queryRecord`: | |||
|
|||
```javascript | |||
// app/adapters/user.js | |||
```app/adapters/user.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change looks unintentional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep yep yep, that was the intention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's cool.
TIL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL too :D
@@ -39,7 +39,7 @@ export function _find(adapter, store, typeClass, id, internalModel, options) { | |||
var payload = normalizeResponseHelper(serializer, store, typeClass, adapterPayload, id, 'findRecord'); | |||
assert('Ember Data expected the primary data returned from a `findRecord` response to be an object but instead it found an array.', !Array.isArray(payload.data)); | |||
|
|||
warn(`You requested a record of type '${typeClass.modelName}' with id '${id}' but the adapter returned a payload with primary data having an id of '${payload.data.id}'. Looks like you want to use store.queryRecord instead http://emberjs.com/api/data/classes/DS.Store.html#method_queryRecord`, payload.data.id === id, { | |||
warn(`You requested a record of type '${typeClass.modelName}' with id '${id}' but the adapter returned a payload with primary data having an id of '${payload.data.id}'. Use 'store.findRecord()' when the requested id is the same as the one returned by the adapter. In other cases use 'store.queryRecord()' instead http://emberjs.com/api/data/classes/DS.Store.html#method_queryRecord`, payload.data.id === id, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Build failure looks unrelated to the changes in this pr restarting. |
Thanks @pangratz. |
Attempt to make it more clear what the action is when your adapter returns a different id than you requested via
store.findRecord()
.This addresses concerns raised in #4604
@bmac can you take a look and check if it is more clear now what the problem is and how it can be solved?