You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TLDR; I'm using this change ActionSprout@4ac52a3, and am wondering if you'd like to support this use case.
Motivation
I use ember-data-url-templates in projects where I either have no control over the api or have to support more complex urls for backwards compatibility. I'd like to also be able to use ember-api-actions in these projects, and use it in an elegant way.
Current Issue
Currently, it is possible to use ember-api-actions with ember-data-url-templates, as long as the resulting url for the api action fits under the format {urlFromTemplate}/{pathFromMemberAction}.
For example:
{// modelripen: memberAction({path: 'ripen'}),// adapterurlTemplate: "/fruits{/id}",}// resultmodel.ripen()// PUT /fruits/1/ripen
However, some scenarios don't work quite as well:
{// modelripen: memberAction({path: 'ripen'}),// adapterurlTemplate: "/fruits{/id}.json",}// resultmodel.ripen()// PUT /fruits/1.json/ripen
Workarounds
The neat thing is that with no changes to either library urlType can be used to configure the url template:
More ideal, I think, would be to not pass a path in memberAction, and instead allow the url template to control the entire url. However this causes an error, as path is required:
{// modelripen: memberAction({urlType: 'ripen'}),// adapterurlTemplate: "/fruits{/id}.json",ripenUrlTemplate: "/fruits/{id}/ripen.json",}// resultmodel.ripen()// error: You must provide a path for instanceOp
Note: I am currently using this configuration with this change ActionSprout@4ac52a3
I imagine that the assert would be important in cases without url templates, so I'm not sure if this would be a good change for all users...
Moving Forward
While I have something working for my current needs, I'd like to set up the best (easy to use and straight forward) integration between ember-api-actions and ember-data-url-templates as possible. If you think my current workaround is a good direction, I'm happy to make a pull-request (with actual tests and less nested ifs). Otherwise, let's discuss. How could it be better?
What are your thoughts?
The text was updated successfully, but these errors were encountered:
Hi, I'd love for
ember-api-actions
andember-data-url-templates
to work well together.TLDR; I'm using this change ActionSprout@4ac52a3, and am wondering if you'd like to support this use case.
Motivation
I use
ember-data-url-templates
in projects where I either have no control over the api or have to support more complex urls for backwards compatibility. I'd like to also be able to useember-api-actions
in these projects, and use it in an elegant way.Current Issue
Currently, it is possible to use
ember-api-actions
withember-data-url-templates
, as long as the resulting url for the api action fits under the format{urlFromTemplate}/{pathFromMemberAction}
.For example:
However, some scenarios don't work quite as well:
Workarounds
The neat thing is that with no changes to either library
urlType
can be used to configure the url template:One solution
More ideal, I think, would be to not pass a
path
inmemberAction
, and instead allow the url template to control the entire url. However this causes an error, aspath
is required:Note: I am currently using this configuration with this change ActionSprout@4ac52a3
I imagine that the assert would be important in cases without url templates, so I'm not sure if this would be a good change for all users...
Moving Forward
While I have something working for my current needs, I'd like to set up the best (easy to use and straight forward) integration between
ember-api-actions
andember-data-url-templates
as possible. If you think my current workaround is a good direction, I'm happy to make a pull-request (with actual tests and less nestedif
s). Otherwise, let's discuss. How could it be better?What are your thoughts?
The text was updated successfully, but these errors were encountered: