{"action":"created","issue":{"url":"https://api.github.com/repos/Shopify/graphql-batch/issues/2","repository_url":"https://api.github.com/repos/Shopify/graphql-batch","labels_url":"https://api.github.com/repos/Shopify/graphql-batch/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/Shopify/graphql-batch/issues/2/comments","events_url":"https://api.github.com/repos/Shopify/graphql-batch/issues/2/events","html_url":"https://github.com/Shopify/graphql-batch/pull/2","id":131119515,"number":2,"title":"Decouple batch querying from graphql-ruby integration.","user":{"login":"dylanahsmith","id":954402,"avatar_url":"https://avatars.githubusercontent.com/u/954402?v=3","gravatar_id":"","url":"https://api.github.com/users/dylanahsmith","html_url":"https://github.com/dylanahsmith","followers_url":"https://api.github.com/users/dylanahsmith/followers","following_url":"https://api.github.com/users/dylanahsmith/following{/other_user}","gists_url":"https://api.github.com/users/dylanahsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/dylanahsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dylanahsmith/subscriptions","organizations_url":"https://api.github.com/users/dylanahsmith/orgs","repos_url":"https://api.github.com/users/dylanahsmith/repos","events_url":"https://api.github.com/users/dylanahsmith/events{/privacy}","received_events_url":"https://api.github.com/users/dylanahsmith/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-03T18:55:41Z","updated_at":"2016-02-03T22:18:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Shopify/graphql-batch/pulls/2","html_url":"https://github.com/Shopify/graphql-batch/pull/2","diff_url":"https://github.com/Shopify/graphql-batch/pull/2.diff","patch_url":"https://github.com/Shopify/graphql-batch/pull/2.patch"},"body":"@eapache for review\r\n\r\n## Problem\r\n\r\nI want to test that all the computed fields on objects are being preloaded properly.  This means that all loading happens during the preload, since loading an association on an individual object will result in an N+1.\r\n\r\nThis will require exposing the ability to call the preload code without it calling the wrapped resolver, as well as the ability to execute any batch queries that are returned the preload code.  The latter is a problem in graphql-batch because the code to execute those queries was coupled with the code to integrate with graphql-ruby.\r\n\r\n## Solution\r\n\r\nI added a `GraphQL::Batch.execute` method that can execute a query container (single query or query group) along with any query container that is returned from a callback of that query.  I have also added a `GraphQL::Batch::QueryContainer#execute` method to make it even easier to execute queries.\r\n\r\nAnother aspect of this refactoring to remove coupling of GraphQL::Batch::ExecutionStrategy with the other code was to allow callbacks to be added on a `GraphQL::Batch::QueryContainer` after it was returned from the resolve proc.  Previously this chaining was done by passing a block to `GraphQL::Batch::Query.new` or `GraphQL::Batch::QueryGroup.new`.  Now `#then` can be used to lazily add a callback.\r\n\r\nI also needed to handle query exceptions in GraphQL::Batch::ExecutionStrategy, so added `#rescue` and `#ensure` on GraphQL::Batch::QueryContainer to handle this in a way that seems somewhat natural for ruby."},"comment":{"url":"https://api.github.com/repos/Shopify/graphql-batch/issues/comments/179502188","html_url":"https://github.com/Shopify/graphql-batch/pull/2#issuecomment-179502188","issue_url":"https://api.github.com/repos/Shopify/graphql-batch/issues/2","id":179502188,"user":{"login":"dylanahsmith","id":954402,"avatar_url":"https://avatars.githubusercontent.com/u/954402?v=3","gravatar_id":"","url":"https://api.github.com/users/dylanahsmith","html_url":"https://github.com/dylanahsmith","followers_url":"https://api.github.com/users/dylanahsmith/followers","following_url":"https://api.github.com/users/dylanahsmith/following{/other_user}","gists_url":"https://api.github.com/users/dylanahsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/dylanahsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dylanahsmith/subscriptions","organizations_url":"https://api.github.com/users/dylanahsmith/orgs","repos_url":"https://api.github.com/users/dylanahsmith/repos","events_url":"https://api.github.com/users/dylanahsmith/events{/privacy}","received_events_url":"https://api.github.com/users/dylanahsmith/received_events","type":"User","site_admin":false},"created_at":"2016-02-03T22:18:49Z","updated_at":"2016-02-03T22:18:49Z","body":"Yes, the API is a lot like promises, but we don't want a promise library that executes the block asynchronously (e.g. using event machine) or concurrently (e.g. in a separate thread)."}}