{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/bookshelf/issues/560","labels_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/560/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/560/comments","events_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/560/events","html_url":"https://github.com/tgriesser/bookshelf/issues/560","id":53307736,"number":560,"title":"introspect fetch queries before they are run","user":{"login":"tkellen","id":1004324,"avatar_url":"https://avatars.githubusercontent.com/u/1004324?v=3","gravatar_id":"","url":"https://api.github.com/users/tkellen","html_url":"https://github.com/tkellen","followers_url":"https://api.github.com/users/tkellen/followers","following_url":"https://api.github.com/users/tkellen/following{/other_user}","gists_url":"https://api.github.com/users/tkellen/gists{/gist_id}","starred_url":"https://api.github.com/users/tkellen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkellen/subscriptions","organizations_url":"https://api.github.com/users/tkellen/orgs","repos_url":"https://api.github.com/users/tkellen/repos","events_url":"https://api.github.com/users/tkellen/events{/privacy}","received_events_url":"https://api.github.com/users/tkellen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-03T16:06:48Z","updated_at":"2015-01-05T05:37:28Z","closed_at":null,"body":"I'm authoring a library that makes [json-api](http://jsonapi.org/) compatible apis using Bookshelf. At the moment, this requires some [gross contortions](https://github.com/endpoints/endpoints-source-bookshelf/blob/master/index.js#L144-L186) to unnest any queries that include relations. You can see [an example app here](http://github.com/endpoints/example). I'd like to implement a way to get a handle on all the query builders that would be used when calling `fetch({withRelated:[...]})`, that way I can call them myself in [endpoints-source-bookshelf](https://github.com/endpoints/endpoints-source-bookshelf/), thus avoiding the un-nesting step. I'm happy to do all the legwork for the implementation (it's high time I started contributing directly to this project), I just want to makes sure you're down with the idea, and to hear your thoughts on what you think the API for this should look like.\r\n\r\n`buildFetch({withRelated:[...]}`?\r\n`fetch{{withRelated:[...], preflight: true})`?\r\n\r\nSomething else?\r\n"},"comment":{"url":"https://api.github.com/repos/tgriesser/bookshelf/issues/comments/68670222","html_url":"https://github.com/tgriesser/bookshelf/issues/560#issuecomment-68670222","issue_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/560","id":68670222,"user":{"login":"tkellen","id":1004324,"avatar_url":"https://avatars.githubusercontent.com/u/1004324?v=3","gravatar_id":"","url":"https://api.github.com/users/tkellen","html_url":"https://github.com/tkellen","followers_url":"https://api.github.com/users/tkellen/followers","following_url":"https://api.github.com/users/tkellen/following{/other_user}","gists_url":"https://api.github.com/users/tkellen/gists{/gist_id}","starred_url":"https://api.github.com/users/tkellen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkellen/subscriptions","organizations_url":"https://api.github.com/users/tkellen/orgs","repos_url":"https://api.github.com/users/tkellen/repos","events_url":"https://api.github.com/users/tkellen/events{/privacy}","received_events_url":"https://api.github.com/users/tkellen/received_events","type":"User","site_admin":false},"created_at":"2015-01-05T05:37:28Z","updated_at":"2015-01-05T05:37:28Z","body":"...a"}}