Skip to content
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

Merged
merged 1 commit into from
Oct 21, 2016
Merged

[DOC] Improve warning for mismatched id in store.findRecord #4609

merged 1 commit into from
Oct 21, 2016

Conversation

pangratz
Copy link
Member

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?

Copy link
Member

@hjdivad hjdivad left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks unintentional

Copy link
Member

@bmac bmac Oct 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is intentional. The markdown parser for JavaScript blocks in the API guides has an enhancement to show the filename in the heading when the filename is included after the three backticks. It uses the file extension to detect what source highlighting should be used.

screen shot 2016-10-21 at 9 54 17 am

vs

screen shot 2016-10-21 at 9 54 47 am

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Contributor

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, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bmac
Copy link
Member

bmac commented Oct 21, 2016

Build failure looks unrelated to the changes in this pr restarting.

@bmac bmac merged commit bae01b8 into emberjs:master Oct 21, 2016
@bmac
Copy link
Member

bmac commented Oct 21, 2016

Thanks @pangratz.

@pangratz pangratz deleted the doc-improve-warning-for-mismatch-id branch October 21, 2016 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants