{"action":"created","issue":{"url":"https://api.github.com/repos/Netflix/falcor/issues/513","labels_url":"https://api.github.com/repos/Netflix/falcor/issues/513/labels{/name}","comments_url":"https://api.github.com/repos/Netflix/falcor/issues/513/comments","events_url":"https://api.github.com/repos/Netflix/falcor/issues/513/events","html_url":"https://github.com/Netflix/falcor/issues/513","id":104383950,"number":513,"title":"Example Falcor DataSource/Model to wrap existing RESTful resources","user":{"login":"baer","id":940667,"avatar_url":"https://avatars.githubusercontent.com/u/940667?v=3","gravatar_id":"","url":"https://api.github.com/users/baer","html_url":"https://github.com/baer","followers_url":"https://api.github.com/users/baer/followers","following_url":"https://api.github.com/users/baer/following{/other_user}","gists_url":"https://api.github.com/users/baer/gists{/gist_id}","starred_url":"https://api.github.com/users/baer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baer/subscriptions","organizations_url":"https://api.github.com/users/baer/orgs","repos_url":"https://api.github.com/users/baer/repos","events_url":"https://api.github.com/users/baer/events{/privacy}","received_events_url":"https://api.github.com/users/baer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-09-02T01:04:35Z","updated_at":"2015-11-09T01:27:39Z","closed_at":null,"body":"So I've now read all of the docs and watched the keynote + the 8 getting started videos and I'm still not that clear on how Falcor orchestrates data fetching. Furthermore since very few of us are lucky enough to work in greenfield projects I'd imagine a very common use case would be to start by wrapping an existing RESTful API. There are two specific scenariaos that I'm not sure about how to deal with:\r\n\r\n---\r\n\r\n* What would be the preferred way to expose the GET lists vs. GET details pattern. These two models effectively nested.\r\n\r\n`GET /users`\r\n```json\r\n[{\r\n  \"id\": \"123\",\r\n  \"givenName\": \"Brandon\",\r\n  \"surame\": \"Pricher\"\r\n}, {\r\n  ...\r\n}]\r\n```\r\n\r\n`GET /users/123`\r\n```json\r\n{\r\n    \"id\": \"123\",\r\n    \"givenName\": \"Brandon\",\r\n    \"surame\": \"Pricher\",\r\n    \"customerLifetimeValue\": \"909869.00\",\r\n    \"preferredLocale\": \"en-US\",\r\n}\r\n```\r\n\r\n---\r\n\r\n* To extend the above, lets say my view needs the Customer + the customer's address. Lets assume we have a user model but the address is an external lookup (USPS address validation for example). On the client sideI might deal with this as follows in the controller but the model seems to have some of this information already encoded in it. Furthermore, if a Falcor client doesn't request address, there is no reason to make that call. Does Falcor orchestrate dependent queries or is there a proper way to handle this?\r\n\r\n```js\r\ngetCustomerViewModel(id) {\r\n  let customer = getCustomer(id)\r\n  let address = customer.then(getCustomerAddress)\r\n\r\n  return Promise.all(customer, address)\r\n    .then((customer, address) => {\r\n      return customer.address = address;\r\n    }).catch(errorHandler)\r\n}\r\n```\r\n\r\nThis is what the view actually needs to render the page\r\n```json\r\n{\r\n    \"id\": \"123\",\r\n    \"givenName\": \"Brandon\",\r\n    \"surame\": \"Pricher\",\r\n    \"customerLifetimeValue\": \"909869.00\",\r\n    \"preferredLocale\": \"en-US\",\r\n    \"address\": {\r\n      \"street\": 123,\r\n      \"city\": \"Memphis\",\r\n      \"zip\": \"38120-0098\" \r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/Netflix/falcor/issues/comments/154898331","html_url":"https://github.com/Netflix/falcor/issues/513#issuecomment-154898331","issue_url":"https://api.github.com/repos/Netflix/falcor/issues/513","id":154898331,"user":{"login":"greim","id":317786,"avatar_url":"https://avatars.githubusercontent.com/u/317786?v=3","gravatar_id":"","url":"https://api.github.com/users/greim","html_url":"https://github.com/greim","followers_url":"https://api.github.com/users/greim/followers","following_url":"https://api.github.com/users/greim/following{/other_user}","gists_url":"https://api.github.com/users/greim/gists{/gist_id}","starred_url":"https://api.github.com/users/greim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greim/subscriptions","organizations_url":"https://api.github.com/users/greim/orgs","repos_url":"https://api.github.com/users/greim/repos","events_url":"https://api.github.com/users/greim/events{/privacy}","received_events_url":"https://api.github.com/users/greim/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T01:27:39Z","updated_at":"2015-11-09T01:27:39Z","body":"Thanks @trxcllnt.\r\n\r\nAlso here's the utility I'm building to convert JSON returned from my REST API objects to JSON graph, if anyone's interested: https://github.com/greim/json-graphify"}}