-
-
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
Predefined query URLs difficult in RESTAdapter #2834
Comments
Agreed that this would be awesome. I tend to deal with these not as cleanly... by using pushPayload and an Ajax request that I manage. ;P |
@hcatlin thanks for the suggestion of a workaround! I'll use that for now :) |
Actually, I have discovered a much, much easier way to do this. In Ember Data, the relationship between the query and the response is pretty loose. That is, the I just realized today, that if I define I don't think you have to do any magic overriding to get this working Let me know if that works! |
And, shit, I think I was wrong. sigh. |
FWIW I'm also overriding |
@jamesarosen @hcatlin @hjdivad there's been work done in the BuildURLMixin that I suspect would make this a lot easier. Would any of you be able to confirm if the |
@wecc what's the reason for making this a mixin rather than having it in the base adapter? |
@hjdivad an adapter doesn't necessarily have to talk to it's storage using AJAX |
@wecc makes sense; still, if the app adapter is already extending |
@hjdivad confirm |
@jamesarosen @hcatlin @hjdivad did overriding |
@wecc can't say, still on an older version of ember-data, I'm afraid. |
Overwriting the urlForFindRecord worked for me ie: return `${namespace}/collection/${id}?${includeItemParam}&${includeLastModifiedUserParam}`; |
Seems to be satisfied by the new buildURL hooks @wecc linked to above. |
I have a model,
User
. In addition to supporting things likeGET /users
andGET /users?page=1
, my server has some predefined optimized filters like/users/active
,/users/inactive
, and/users/recently-created
.I'm trying to write a
UserAdapter
that supports this, but I'm having trouble.Attempt 1
My first instinct was to define
buildURL
, but that function doesn't get thequery
.RESTAdapter.prototype.findQuery
looks like this:That is, it just tacks the query on to the all URL as query parameters.
Attempt 2
My second idea was to override
findQuery
itself. Its surface area is fairly small, so that would be pretty easy:This works -- in theory. The problem is that
findQuery
is private, which means I'm not allowed to override it in my adapter.Recommendation
Either
buildURL
tobuildURL(type, id, record, query)
findQuery
protected or publicThe text was updated successfully, but these errors were encountered: