{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/data/issues/2834","labels_url":"https://api.github.com/repos/emberjs/data/issues/2834/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/data/issues/2834/comments","events_url":"https://api.github.com/repos/emberjs/data/issues/2834/events","html_url":"https://github.com/emberjs/data/issues/2834","id":60061328,"number":2834,"title":"Predefined query URLs difficult in RESTAdapter","user":{"login":"jamesarosen","id":2406,"avatar_url":"https://avatars.githubusercontent.com/u/2406?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesarosen","html_url":"https://github.com/jamesarosen","followers_url":"https://api.github.com/users/jamesarosen/followers","following_url":"https://api.github.com/users/jamesarosen/following{/other_user}","gists_url":"https://api.github.com/users/jamesarosen/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesarosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesarosen/subscriptions","organizations_url":"https://api.github.com/users/jamesarosen/orgs","repos_url":"https://api.github.com/users/jamesarosen/repos","events_url":"https://api.github.com/users/jamesarosen/events{/privacy}","received_events_url":"https://api.github.com/users/jamesarosen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-03-06T05:30:22Z","updated_at":"2015-06-02T20:50:08Z","closed_at":null,"body":"I have a model, `User`. In addition to supporting things like `GET /users` and `GET /users?page=1`, my server has some predefined optimized filters like `/users/active`, `/users/inactive`, and `/users/recently-created`.\r\n\r\nI'm trying to write a `UserAdapter` that supports this, but I'm having trouble.\r\n\r\n### Attempt 1\r\n\r\nMy first instinct was to define `buildURL`, but that function doesn't get the `query`. `RESTAdapter.prototype.findQuery` looks like [this](https://github.com/emberjs/data/blob/c13a61bab6662255b7195f98dc0af0c5802228e3/packages/ember-data/lib/adapters/rest_adapter.js#L388-L393):\r\n\r\n```js\r\nfindQuery: function(store, type, query) {\r\n  if (this.sortQueryParams) {\r\n    query = this.sortQueryParams(query);\r\n  }\r\n  return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query });\r\n}\r\n```\r\n\r\nThat is, it just tacks the query on to the _all_ URL as query parameters.\r\n\r\n### Attempt 2\r\n\r\nMy second idea was to override `findQuery` itself. Its surface area is fairly small, so that would be pretty easy:\r\n\r\n```js\r\nfindQuery: function(store, type, query) {\r\n  if (this.sortQueryParams) {\r\n    query = this.sortQueryParams(query);\r\n  }\r\n  var url = this.buildURL(type.typeKey);\r\n  if (query.subset) {\r\n    url += '/' + subset;\r\n    delete query.subset;\r\n  }\r\n  return this.ajax(url, 'GET', { data: query });\r\n}\r\n```\r\nThis works -- in theory. The problem is that `findQuery` is _private_, which means I'm not allowed to override it in my adapter.\r\n\r\n### Recommendation\r\n\r\nEither\r\n\r\n 1. change the API of `buildURL` to `buildURL(type, id, record, query)`\r\n 2. make `findQuery` protected or public"},"comment":{"url":"https://api.github.com/repos/emberjs/data/issues/comments/108095428","html_url":"https://github.com/emberjs/data/issues/2834#issuecomment-108095428","issue_url":"https://api.github.com/repos/emberjs/data/issues/2834","id":108095428,"user":{"login":"wecc","id":708205,"avatar_url":"https://avatars.githubusercontent.com/u/708205?v=3","gravatar_id":"","url":"https://api.github.com/users/wecc","html_url":"https://github.com/wecc","followers_url":"https://api.github.com/users/wecc/followers","following_url":"https://api.github.com/users/wecc/following{/other_user}","gists_url":"https://api.github.com/users/wecc/gists{/gist_id}","starred_url":"https://api.github.com/users/wecc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wecc/subscriptions","organizations_url":"https://api.github.com/users/wecc/orgs","repos_url":"https://api.github.com/users/wecc/repos","events_url":"https://api.github.com/users/wecc/events{/privacy}","received_events_url":"https://api.github.com/users/wecc/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T20:50:08Z","updated_at":"2015-06-02T20:50:08Z","body":"@hjdivad an adapter doesn't necessarily have to talk to the storage with AJAX"}}