-
-
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
Break buildURL into multiple requestType methods #2966
Conversation
@bmac can you add this to the friday team discussion? |
Break buildURL into multiple requestType methods
@@ -391,7 +391,7 @@ export default Adapter.extend(BuildURLMixin, { | |||
@return {Promise} promise | |||
*/ | |||
findQuery: function(store, type, query) { | |||
var url = this.buildURL(type.typeKey, null, null, 'findQuery'); | |||
var url = this.buildURL(type.typeKey, query, null, 'findQuery'); |
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.
Is this related to the PR in question?
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.
Thanks for passing query
along to buildURL
; I will find that useful!
I'm wondering, though, why is it passed as the id
parameter and would it make more sense as the snapshot
parameter? I know it's not really a snapshot, but it seems more like a snapshot than an id. Before this change, id
is either null
, a string, or an array of strings. With this change it can also be an object. snapshot
on the other hand, is either null
, an object, or an array of objects. Also, I think the query
is used similarly as the snapshot (to fill arbitrary values in the url).
For reference, here is the signature of buildURL
:
buildURL: function(type, id, snapshot, requestType) {
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.
That would be a breaking change for anyone currently overriding buildURL
that is expecting it to be an actual snapshot. And I would say that the breaking change should be adding a formal query
argument so that the signature would be:
buildURL: function(type, id, query, snapshot, requestType) {
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.
ok
I just thought I would check. I don't understand how putting the using query
instead of null
would break anything that using query
instead of id
would, but it sounds like you've thought about this more in depth than I have.
Anyway, I'm just happy to have the query available in buildURL at all. Thanks!
In emberjs/data#2966 ember-data started passing the `query` from `findQuery` to `buildURL` as the `id` parameter.
@thejameskyle does this satisfy your requirements or do you still need more stuff here? |
I understand the benefits for when you want to override particular queries, but what is the reasoning for making the actual url construction ( Here's a usecase I had:
To avoid using the private _buildURL, I only see adding the same custom code to 10 different methods? |
Could you override buildUrl and call super? |
My override inserts a segment somewhere in the middle of the generated url, so while theoretically it could be possible to insert the needed part within The new buildUrl branches to 10 different methods based on request type ( |
I don't see how that would improve anything. Calling super here should behave almost exactly the way it did previously for your case. |
@thejameskyle are you referring to calling super in the new |
This provides separate abstract methods that can be used for different request types with better signatures. It also passes the
query
in fromfindQuery
.I still need to write tests for this, but I'm putting it up before I go to sleep.
PS: @wycats I still want to be able to pass query to
findAll
but I wasn't able to find a good way of doing that.