{"action":"created","comment":{"url":"https://api.github.com/repos/graphql-python/graphene/pulls/comments/48094324","id":48094324,"diff_hunk":"@@ -0,0 +1,28 @@\n+from functools import wraps\n+from graphql.core.utils.get_field_def import get_field_def\n+from graphql.core.type.definition import GraphQLList, GraphQLNonNull\n+\n+\n+def get_fields(info):\n+    field_asts = info.field_asts[0].selection_set.selections\n+    only_args = []\n+    _type = info.return_type\n+    if isinstance(_type, (GraphQLList, GraphQLNonNull)):\n+        _type = _type.of_type\n+\n+    for field in field_asts:\n+        field_def = get_field_def(info.schema, _type, field)\n+        f = field_def.resolver\n+        fetch_field = getattr(f, 'django_fetch_field', None)\n+        if not fetch_field:\n+            continue\n+        only_args.append(fetch_field.attname)\n+    return only_args","path":"graphene/contrib/django/fetcher.py","position":20,"original_position":20,"commit_id":"b331d6ba41d85517c8a1b8a91f8f3338e0301ce7","original_commit_id":"b331d6ba41d85517c8a1b8a91f8f3338e0301ce7","user":{"login":"Globegitter","id":2580254,"avatar_url":"https://avatars.githubusercontent.com/u/2580254?v=3","gravatar_id":"","url":"https://api.github.com/users/Globegitter","html_url":"https://github.com/Globegitter","followers_url":"https://api.github.com/users/Globegitter/followers","following_url":"https://api.github.com/users/Globegitter/following{/other_user}","gists_url":"https://api.github.com/users/Globegitter/gists{/gist_id}","starred_url":"https://api.github.com/users/Globegitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Globegitter/subscriptions","organizations_url":"https://api.github.com/users/Globegitter/orgs","repos_url":"https://api.github.com/users/Globegitter/repos","events_url":"https://api.github.com/users/Globegitter/events{/privacy}","received_events_url":"https://api.github.com/users/Globegitter/received_events","type":"User","site_admin":false},"body":"Good catch @bigblind - that would be great to have in graphene core/`ResolveInfo`","created_at":"2015-12-19T16:51:22Z","updated_at":"2015-12-19T16:51:22Z","html_url":"https://github.com/graphql-python/graphene/pull/67#discussion_r48094324","pull_request_url":"https://api.github.com/repos/graphql-python/graphene/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/graphql-python/graphene/pulls/comments/48094324"},"html":{"href":"https://github.com/graphql-python/graphene/pull/67#discussion_r48094324"},"pull_request":{"href":"https://api.github.com/repos/graphql-python/graphene/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/graphql-python/graphene/pulls/67","id":53214057,"html_url":"https://github.com/graphql-python/graphene/pull/67","diff_url":"https://github.com/graphql-python/graphene/pull/67.diff","patch_url":"https://github.com/graphql-python/graphene/pull/67.patch","issue_url":"https://api.github.com/repos/graphql-python/graphene/issues/67","number":67,"state":"open","locked":false,"title":"Optimize Django SQL queries based on the GraphQL queries fields","user":{"login":"syrusakbary","id":188257,"avatar_url":"https://avatars.githubusercontent.com/u/188257?v=3","gravatar_id":"","url":"https://api.github.com/users/syrusakbary","html_url":"https://github.com/syrusakbary","followers_url":"https://api.github.com/users/syrusakbary/followers","following_url":"https://api.github.com/users/syrusakbary/following{/other_user}","gists_url":"https://api.github.com/users/syrusakbary/gists{/gist_id}","starred_url":"https://api.github.com/users/syrusakbary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syrusakbary/subscriptions","organizations_url":"https://api.github.com/users/syrusakbary/orgs","repos_url":"https://api.github.com/users/syrusakbary/repos","events_url":"https://api.github.com/users/syrusakbary/events{/privacy}","received_events_url":"https://api.github.com/users/syrusakbary/received_events","type":"User","site_admin":false},"body":"As GraphQL provides a way for fetching only certain fields, the Django mapper should adapt for querying only what is requested. That means using `model.objects.only(*requested_fields)` as will be much more performant.","created_at":"2015-12-10T04:20:50Z","updated_at":"2015-12-19T16:51:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8ade9a50982709117ce84714b458524cffe34ba6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/graphql-python/graphene/pulls/67/commits","review_comments_url":"https://api.github.com/repos/graphql-python/graphene/pulls/67/comments","review_comment_url":"https://api.github.com/repos/graphql-python/graphene/pulls/comments{/number}","comments_url":"https://api.github.com/repos/graphql-python/graphene/issues/67/comments","statuses_url":"https://api.github.com/repos/graphql-python/graphene/statuses/b331d6ba41d85517c8a1b8a91f8f3338e0301ce7","head":{"label":"graphql-python:features/django-debug-optimize","ref":"features/django-debug-optimize","sha":"b331d6ba41d85517c8a1b8a91f8f3338e0301ce7","user":{"login":"graphql-python","id":15002022,"avatar_url":"https://avatars.githubusercontent.com/u/15002022?v=3","gravatar_id":"","url":"https://api.github.com/users/graphql-python","html_url":"https://github.com/graphql-python","followers_url":"https://api.github.com/users/graphql-python/followers","following_url":"https://api.github.com/users/graphql-python/following{/other_user}","gists_url":"https://api.github.com/users/graphql-python/gists{/gist_id}","starred_url":"https://api.github.com/users/graphql-python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphql-python/subscriptions","organizations_url":"https://api.github.com/users/graphql-python/orgs","repos_url":"https://api.github.com/users/graphql-python/repos","events_url":"https://api.github.com/users/graphql-python/events{/privacy}","received_events_url":"https://api.github.com/users/graphql-python/received_events","type":"Organization","site_admin":false},"repo":{"id":43056951,"name":"graphene","full_name":"graphql-python/graphene","owner":{"login":"graphql-python","id":15002022,"avatar_url":"https://avatars.githubusercontent.com/u/15002022?v=3","gravatar_id":"","url":"https://api.github.com/users/graphql-python","html_url":"https://github.com/graphql-python","followers_url":"https://api.github.com/users/graphql-python/followers","following_url":"https://api.github.com/users/graphql-python/following{/other_user}","gists_url":"https://api.github.com/users/graphql-python/gists{/gist_id}","starred_url":"https://api.github.com/users/graphql-python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphql-python/subscriptions","organizations_url":"https://api.github.com/users/graphql-python/orgs","repos_url":"https://api.github.com/users/graphql-python/repos","events_url":"https://api.github.com/users/graphql-python/events{/privacy}","received_events_url":"https://api.github.com/users/graphql-python/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/graphql-python/graphene","description":"GraphQL framework for Python","fork":false,"url":"https://api.github.com/repos/graphql-python/graphene","forks_url":"https://api.github.com/repos/graphql-python/graphene/forks","keys_url":"https://api.github.com/repos/graphql-python/graphene/keys{/key_id}","collaborators_url":"https://api.github.com/repos/graphql-python/graphene/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/graphql-python/graphene/teams","hooks_url":"https://api.github.com/repos/graphql-python/graphene/hooks","issue_events_url":"https://api.github.com/repos/graphql-python/graphene/issues/events{/number}","events_url":"https://api.github.com/repos/graphql-python/graphene/events","assignees_url":"https://api.github.com/repos/graphql-python/graphene/assignees{/user}","branches_url":"https://api.github.com/repos/graphql-python/graphene/branches{/branch}","tags_url":"https://api.github.com/repos/graphql-python/graphene/tags","blobs_url":"https://api.github.com/repos/graphql-python/graphene/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/graphql-python/graphene/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/graphql-python/graphene/git/refs{/sha}","trees_url":"https://api.github.com/repos/graphql-python/graphene/git/trees{/sha}","statuses_url":"https://api.github.com/repos/graphql-python/graphene/statuses/{sha}","languages_url":"https://api.github.com/repos/graphql-python/graphene/languages","stargazers_url":"https://api.github.com/repos/graphql-python/graphene/stargazers","contributors_url":"https://api.github.com/repos/graphql-python/graphene/contributors","subscribers_url":"https://api.github.com/repos/graphql-python/graphene/subscribers","subscription_url":"https://api.github.com/repos/graphql-python/graphene/subscription","commits_url":"https://api.github.com/repos/graphql-python/graphene/commits{/sha}","git_commits_url":"https://api.github.com/repos/graphql-python/graphene/git/commits{/sha}","comments_url":"https://api.github.com/repos/graphql-python/graphene/comments{/number}","issue_comment_url":"https://api.github.com/repos/graphql-python/graphene/issues/comments{/number}","contents_url":"https://api.github.com/repos/graphql-python/graphene/contents/{+path}","compare_url":"https://api.github.com/repos/graphql-python/graphene/compare/{base}...{head}","merges_url":"https://api.github.com/repos/graphql-python/graphene/merges","archive_url":"https://api.github.com/repos/graphql-python/graphene/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/graphql-python/graphene/downloads","issues_url":"https://api.github.com/repos/graphql-python/graphene/issues{/number}","pulls_url":"https://api.github.com/repos/graphql-python/graphene/pulls{/number}","milestones_url":"https://api.github.com/repos/graphql-python/graphene/milestones{/number}","notifications_url":"https://api.github.com/repos/graphql-python/graphene/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/graphql-python/graphene/labels{/name}","releases_url":"https://api.github.com/repos/graphql-python/graphene/releases{/id}","created_at":"2015-09-24T09:18:18Z","updated_at":"2015-12-18T13:51:22Z","pushed_at":"2015-12-18T18:27:44Z","git_url":"git://github.com/graphql-python/graphene.git","ssh_url":"git@github.com:graphql-python/graphene.git","clone_url":"https://github.com/graphql-python/graphene.git","svn_url":"https://github.com/graphql-python/graphene","homepage":"http://graphene-python.org/","size":11892,"stargazers_count":253,"watchers_count":253,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":19,"mirror_url":null,"open_issues_count":14,"forks":19,"open_issues":14,"watchers":253,"default_branch":"master"}},"base":{"label":"graphql-python:master","ref":"master","sha":"e27af63f3a4bd28ae72478778fde75e463882def","user":{"login":"graphql-python","id":15002022,"avatar_url":"https://avatars.githubusercontent.com/u/15002022?v=3","gravatar_id":"","url":"https://api.github.com/users/graphql-python","html_url":"https://github.com/graphql-python","followers_url":"https://api.github.com/users/graphql-python/followers","following_url":"https://api.github.com/users/graphql-python/following{/other_user}","gists_url":"https://api.github.com/users/graphql-python/gists{/gist_id}","starred_url":"https://api.github.com/users/graphql-python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphql-python/subscriptions","organizations_url":"https://api.github.com/users/graphql-python/orgs","repos_url":"https://api.github.com/users/graphql-python/repos","events_url":"https://api.github.com/users/graphql-python/events{/privacy}","received_events_url":"https://api.github.com/users/graphql-python/received_events","type":"Organization","site_admin":false},"repo":{"id":43056951,"name":"graphene","full_name":"graphql-python/graphene","owner":{"login":"graphql-python","id":15002022,"avatar_url":"https://avatars.githubusercontent.com/u/15002022?v=3","gravatar_id":"","url":"https://api.github.com/users/graphql-python","html_url":"https://github.com/graphql-python","followers_url":"https://api.github.com/users/graphql-python/followers","following_url":"https://api.github.com/users/graphql-python/following{/other_user}","gists_url":"https://api.github.com/users/graphql-python/gists{/gist_id}","starred_url":"https://api.github.com/users/graphql-python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphql-python/subscriptions","organizations_url":"https://api.github.com/users/graphql-python/orgs","repos_url":"https://api.github.com/users/graphql-python/repos","events_url":"https://api.github.com/users/graphql-python/events{/privacy}","received_events_url":"https://api.github.com/users/graphql-python/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/graphql-python/graphene","description":"GraphQL framework for Python","fork":false,"url":"https://api.github.com/repos/graphql-python/graphene","forks_url":"https://api.github.com/repos/graphql-python/graphene/forks","keys_url":"https://api.github.com/repos/graphql-python/graphene/keys{/key_id}","collaborators_url":"https://api.github.com/repos/graphql-python/graphene/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/graphql-python/graphene/teams","hooks_url":"https://api.github.com/repos/graphql-python/graphene/hooks","issue_events_url":"https://api.github.com/repos/graphql-python/graphene/issues/events{/number}","events_url":"https://api.github.com/repos/graphql-python/graphene/events","assignees_url":"https://api.github.com/repos/graphql-python/graphene/assignees{/user}","branches_url":"https://api.github.com/repos/graphql-python/graphene/branches{/branch}","tags_url":"https://api.github.com/repos/graphql-python/graphene/tags","blobs_url":"https://api.github.com/repos/graphql-python/graphene/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/graphql-python/graphene/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/graphql-python/graphene/git/refs{/sha}","trees_url":"https://api.github.com/repos/graphql-python/graphene/git/trees{/sha}","statuses_url":"https://api.github.com/repos/graphql-python/graphene/statuses/{sha}","languages_url":"https://api.github.com/repos/graphql-python/graphene/languages","stargazers_url":"https://api.github.com/repos/graphql-python/graphene/stargazers","contributors_url":"https://api.github.com/repos/graphql-python/graphene/contributors","subscribers_url":"https://api.github.com/repos/graphql-python/graphene/subscribers","subscription_url":"https://api.github.com/repos/graphql-python/graphene/subscription","commits_url":"https://api.github.com/repos/graphql-python/graphene/commits{/sha}","git_commits_url":"https://api.github.com/repos/graphql-python/graphene/git/commits{/sha}","comments_url":"https://api.github.com/repos/graphql-python/graphene/comments{/number}","issue_comment_url":"https://api.github.com/repos/graphql-python/graphene/issues/comments{/number}","contents_url":"https://api.github.com/repos/graphql-python/graphene/contents/{+path}","compare_url":"https://api.github.com/repos/graphql-python/graphene/compare/{base}...{head}","merges_url":"https://api.github.com/repos/graphql-python/graphene/merges","archive_url":"https://api.github.com/repos/graphql-python/graphene/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/graphql-python/graphene/downloads","issues_url":"https://api.github.com/repos/graphql-python/graphene/issues{/number}","pulls_url":"https://api.github.com/repos/graphql-python/graphene/pulls{/number}","milestones_url":"https://api.github.com/repos/graphql-python/graphene/milestones{/number}","notifications_url":"https://api.github.com/repos/graphql-python/graphene/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/graphql-python/graphene/labels{/name}","releases_url":"https://api.github.com/repos/graphql-python/graphene/releases{/id}","created_at":"2015-09-24T09:18:18Z","updated_at":"2015-12-18T13:51:22Z","pushed_at":"2015-12-18T18:27:44Z","git_url":"git://github.com/graphql-python/graphene.git","ssh_url":"git@github.com:graphql-python/graphene.git","clone_url":"https://github.com/graphql-python/graphene.git","svn_url":"https://github.com/graphql-python/graphene","homepage":"http://graphene-python.org/","size":11892,"stargazers_count":253,"watchers_count":253,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":19,"mirror_url":null,"open_issues_count":14,"forks":19,"open_issues":14,"watchers":253,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/graphql-python/graphene/pulls/67"},"html":{"href":"https://github.com/graphql-python/graphene/pull/67"},"issue":{"href":"https://api.github.com/repos/graphql-python/graphene/issues/67"},"comments":{"href":"https://api.github.com/repos/graphql-python/graphene/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/graphql-python/graphene/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/graphql-python/graphene/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/graphql-python/graphene/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/graphql-python/graphene/statuses/b331d6ba41d85517c8a1b8a91f8f3338e0301ce7"}}}}