-
Notifications
You must be signed in to change notification settings - Fork 32
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
Payload warnings #24
Comments
👍 on filter the warning |
I don't use ember-data-storefront but I'm using similar patterns, i.e. async relationships everywhere but with links in the payload too. Therefore I am seeing a lot of these warnings. I filtered out these warnings by adding the following initializer to my app: // app/initializers/warnings-to-ignore.js
import { registerWarnHandler } from '@ember/debug';
const IGNORED_WARNINGS = [
'ds.store.push-link-for-sync-relationship'
];
export default {
name: 'warnings-to-ignore',
initialize() {
registerWarnHandler(function(message, options, next) {
if (!ignoreWarning(options)) {
next(...arguments);
}
});
}
};
function ignoreWarning(options) {
return options && options.id && IGNORED_WARNINGS.includes(options.id);
} This uses the API described in RFC 65. I thought I'd share this snippet as it might help getting the functionality into the addon! |
Awesome! That looks great. I think this is a good first PR for anyone who wants to get involved w/ storefront! |
Hmm, I ran into this a while back and went with the solution posted by @YoranBrondsema. Worked great, but, I just updated to Ember 3.7 and now the warnings are back. It doesn't look like the warn handler isn't even being called any more -- has anyone experienced this, by chance? |
Hey @XaserAcheron, I just leveraged successfully in my Ember-3.10 app. Is you import correct: |
RE: everyone. Hacking the solution via deleting links is a poor solution. Why can't Here's what a normal human would expect: with User -> Posts, when I have async:false, when I query User, it should ajax to /users, and then discover links, then ajax to Anything else is just lazily exposing the sausage-making. Fetching User is an ajax call, which takes time, and is async. I don't care how many calls are shoved/packed into it, because I'm already async at that point. The goal/point of async:false is maintained, regardless of how many sausage-making underlying ajax calls that requires. This is one of those reasons that React is better than Ember. They take no position, which makes ember-data's poor decision worse for developers to learn. It's easier to make it work when you make it yourself. It's harder to make it work when the framework you're expected to make work has warts. Hiding warnings is not the same thing as fixing the problem. Hiding the warnings makes the code-that-works even harder to understand for someone else. Random people who "see Ember code" just scratch their head later. YOU know why those warnings were hidden (and where they were hidden)... but who else? Sure, the problem is with
IF that's not possible (I honestly have no idea), then I recommend including the problem (and recommendation for solutions) it in the docs. I spent the entire day integrating Yes. I'm bitter. Thanks for listening to my rant. Maybe I'm barking up the right tree. Just like my dog, sometimes barking is all I have... :) I advocate for the principle of least surprise. Masking over warnings is not that. |
@msmyers I appreciate you sharing your thoughts – sounds like you had a rough day! Believe, I've been there and I understand how frustrating this stuff can be. Since this is all fresh in your mind, I'd love to ask you a few questions:
As far as your recommendation to change Ember Data's async find behavior, I'm not sure I understand what you're proposing. Are you saying if you were to use one of Storefront's APIs (e.g. The real problem is the impedance mismatch between how many people use Did you try to use the warning suppression in this issue? Did you find it surprising? Or are you talking about some other aspect of Storefront? Thanks again for the issue & I look forward to hearing your feedback! |
Thanks for the quick reply and opportunity to share my recent experiences. I am starting a brand new project, using ember and sails, with the sails-ember-rest plugin. With
I knew that I wanted to have 4 levels of one-to-many, and googled best-practices. I came across a blog entry that made a compelling argument/rationale for leveraging The selling point was the ability to crash if not preloaded, plus the ability to wire up computed properties. I built other projects in sails/ember, and wanted to avoid the pain of promise-aware templates.
Now that I think about it, I'm pretty happy with how it snapped into my project. I don't have any requested changes. I believe the problem was potentially in my understanding and expectations of the library. |
Gotcha. I'm guessing the blog post you're referring to is this one of ours: https://embermap.com/notes/83-the-case-against-async-relationships There's indeed some confusing pieces here because of the overlap with Ember Data's APIs and Storefront, which really can be thought of an opinionated way to use Ember Data. I think there's a place in the guides under the [Avoiding async relationships](Avoiding async relationships) section to explain this warning, that it's coming from Ember Data (not Storefront), and why it doesn't affect Storefront's functionality or cache. |
With sync relationships the presence of a link throws an error. Let's filter these warnings out.
The text was updated successfully, but these errors were encountered: