-
-
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
make shouldSerializeHasMany public #2494 #4279
Conversation
Thanks @jondayton. Since this change is going to add a new method to Ember Data's public api would you mind wrapping it in a feature flag? |
@bmac no problem. In that case, since it's removing the private api and adding the public, it may be better to leave the private method and add a public reference under the feature flag |
Good plan @jondayton. |
@bmac added a deprecation warning + test. I've been looking at it again and making this a feature flag will require either warnings in several places or a third private method |
var relationshipType = snapshot.type.determineRelationshipType(relationship, this.store); | ||
shouldSerializeHasMany(snapshot, key, relationship) { | ||
if (this._shouldSerializeHasMany) { | ||
deprecate('The private method `_shouldSerializeHasMany` has been deprecated. Please use public method `shouldSerializeHasMany`.', false, { |
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.
I think "The private method _shouldSerializeHasMany
has been promoted to the public API. Please remove the underscore to use the public shouldSerializeHasMany
method instead." might be a bit better description of what's going on.
Needs a feature flag, we should also make a shouldSerializeBelongsTo as well |
sounds good. I'll take a pass at it tonight. |
ping @jondayton do you have time to update this pr? |
@bmac updated the pr with a feature flag. |
logic goes something like this
technically we could break people who are overriding the private method without a deprecation warning, but I do think it's better to throw the warning. I used |
Thanks @jondayton. This looks good. Do you mind rebasing this one last time and I will merge it? |
@@ -571,8 +571,9 @@ const JSONAPISerializer = JSONSerializer.extend({ | |||
*/ | |||
serializeHasMany(snapshot, json, relationship) { | |||
var key = relationship.key; | |||
var shouldSerializeHasMany = isEnabled('ds-check-should-serialize-relationships') ? 'shouldSerializeHasMany' : '__shouldSerializeHasMany'; |
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.
Unfortunately this doesn't work so the feature is correctly stripped in production. You need to change this to something like:
var shouldSerializeHasMany = '__shouldSerializeHasMany';
if (isEnabled("ds-check-should-serialize-relationships")) {
shouldSerializeHasMany = 'shouldSerializeHasMany';
}
Sorry @jondayton. @pangratz reminded me that we've been using another pattern for detecting deprecated functions. I added a few comments. |
@bmac was out of town for the long weekend but should have some time tonight. |
@bmac took another pass at it. |
Thanks @jondayton |
From #2494