Open tkellen opened 9 years ago
It looks it is possible and that's exactly the point where I am trying to solve on my project. The include parameter already works but when I use the async parameter in the model entries, it's not looking at the host and namespace.
link.related
is a relative url and it's necessary to apply the host and namespace.
This can be seen at:
https://github.com/endpoints/ember-data-endpoints/blob/master/addon/json-api-adapter.js#L66
Where I changed both findBelongsTo
and findHasMany
to:
url = `${Ember.get(this,'host')}/${Ember.get(this,'namespace')}${link.related}`;
Interesting. I feel like endpoints should be returning the full url here. @tkellen thoughts?
No prob, I can update this (will do first thing tomorrow) It seems like relative URLs should work tho?
On Apr 30, 2015, at 6:04 PM, Brendan McLoughlin notifications@github.com wrote:
Interesting. I feel like endpoints should be returning the full url here. @tkellen https://github.com/tkellen thoughts?
— Reply to this email directly or view it on GitHub https://github.com/endpoints/ember-data-endpoints/issues/9#issuecomment-97983874 .
@leobalter what does the JSON response from the endpoint look like? For some reason I can't get the v2 version of my api to work.
Thanks @leobalter.
@tkellen, I'd prefer not to add the complexity to the adapter to make it try and decide if it needs to add the namespace to a links
url. However, if we and/or Ember Data did go down that route then I think these urls should not begin with a /
as it makes them look like absolute urls instead of relative urls.
@bmac Try re-running get-secrets and provisioning? Working on the URLs thing now.
PS: I need to update the API to only run one version--the one you have checked out on your local machine.
The current deployment setup for the API clones and checks out each version--if you set currentVersion
in group_vars/all.yml
to v2, it will use the code you have checked out locally. Otherwise it's just a folder on the VM that you don't have access to from your local machine. Whoops.
/cc @bobholt if you have any more trouble.
IMHO, this looks very like an adapter responsibility. As the host and namespace is part of the adapter settings, relative links should also be resolved by the adapter.
My implementation on #18 is only a workaround and it needs to be improved (needs to check the existence of values, etc) but it seems weird to get the resolved url on the other cases.
@leobalter I disagree. The logic for building the urls should live in the server. It makes it easier to change that logic or update the url in the future without also requiring a change in the client.
Some context: In this example, an organization has projects and a project has phases. Sometimes, a user may wish to see the organization related to the phase, but not want the intermediate project record in the response. This can be accomplished using endpoints with the following:
GET /project-phases/12?include=project.organizations
Is supporting this even possible with ember-data @bmac?