-
-
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
Pass requestType to buildURL #2898
Conversation
Can you rebase? Seems like it's not merging cleanly |
d863109
to
e3dfab8
Compare
Rebased, sorry about that. |
var data = {}; | ||
var serializer = store.serializerFor(type.typeKey); | ||
var snapshot = record._createSnapshot(); | ||
var url = this.buildURL(type.typeKey, null, snapshot, 'createRecord'); |
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.
The code for createRecord
pass 'create'
to buildURL, but in this example it's 'createRecord'
, typo?
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.
Good catch. Which do you think it should be?
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 it makes sense to keep it consistent with the method names?
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'll go with that.
I think I was thinking that the method names were an implementation detail, but I think the consistency would be worth it.
Thanks for your input :)
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've changed these all to match the original function name (createRecord
, updateRecord
, etc)
|
||
if (sinceToken) { | ||
query = { since: sinceToken }; | ||
} | ||
|
||
return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query }); | ||
url = this.buildURL(type.typeKey, undefined, undefined, 'findAll'); |
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.
Could these missing arguments be null
instead of undefined
? This will make it more consistent with https://github.com/emberjs/data/pull/2898/files#diff-24089ab4caa677e410cbc5c13588c012L533
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.
Done. Good idea
👍 |
I've made changes suggested by @bmac, but I need to rebase again. |
a9f8331
to
11b06f0
Compare
This is another step toward emberjs/rfcs#4. Once url-templates lands, most users extending BuildURLMixin will not need to handle requestType explicitly, as it will be possible to define a template for each request type. Also move buildURL specific RESTAdapter tests to a new file
11b06f0
to
ff35ee7
Compare
@igorT this should be ready now. |
Thanks @amiel! |
Thank you! |
👍 |
This is another step toward emberjs/rfcs#4.
Others have requested ways to handle different urls per request type (see #1078).
Once url-templates lands, most users extending
BuildURLMixin
will not need to handlerequestType
explicitly, as it will be possible to define a template for each request type.