{"action":"created","issue":{"url":"https://api.github.com/repos/graphql-python/graphene-django/issues/437","repository_url":"https://api.github.com/repos/graphql-python/graphene-django","labels_url":"https://api.github.com/repos/graphql-python/graphene-django/issues/437/labels{/name}","comments_url":"https://api.github.com/repos/graphql-python/graphene-django/issues/437/comments","events_url":"https://api.github.com/repos/graphql-python/graphene-django/issues/437/events","html_url":"https://github.com/graphql-python/graphene-django/issues/437","id":321227359,"number":437,"title":"DjangoFilterConnectionField with DataLoader","user":{"login":"patrys","id":81205,"avatar_url":"https://avatars1.githubusercontent.com/u/81205?v=4","gravatar_id":"","url":"https://api.github.com/users/patrys","html_url":"https://github.com/patrys","followers_url":"https://api.github.com/users/patrys/followers","following_url":"https://api.github.com/users/patrys/following{/other_user}","gists_url":"https://api.github.com/users/patrys/gists{/gist_id}","starred_url":"https://api.github.com/users/patrys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrys/subscriptions","organizations_url":"https://api.github.com/users/patrys/orgs","repos_url":"https://api.github.com/users/patrys/repos","events_url":"https://api.github.com/users/patrys/events{/privacy}","received_events_url":"https://api.github.com/users/patrys/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-08T15:07:53Z","updated_at":"2018-05-15T16:53:32Z","closed_at":null,"author_association":"NONE","body":"Consider a query like this:\r\n\r\n```graphql\r\n{\r\n    category(id: 1) {\r\n        products {\r\n            edges {\r\n                node {\r\n                    category {\r\n                        products {\r\n                            edges {\r\n                                node {\r\n                                    category {\r\n                                        products {\r\n                                            edges {\r\n                                                node {\r\n                                                    id\r\n                                                }\r\n                                            }\r\n                                        }\r\n                                    }\r\n                                }\r\n                            }\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nIf someone runs a query like this we are possibly executing hundreds of queries even if the response contains a fairly small number of unique objects. We can use a `DataLoader` for the `product.category` relation but as `category.products` is a `DjangoFilterConnectionField` I see no way to have it memorize results within the same execution context.\r\n\r\nIdeally I'd want it to only query the database once for each unique combination of `category.id` and input parameters (pagination, filterset data). Currently it will fetch the category, then fetch all its products, then for each result once again fetch all products in the category and then once again fetch all products in the category for each of those."},"comment":{"url":"https://api.github.com/repos/graphql-python/graphene-django/issues/comments/389237668","html_url":"https://github.com/graphql-python/graphene-django/issues/437#issuecomment-389237668","issue_url":"https://api.github.com/repos/graphql-python/graphene-django/issues/437","id":389237668,"user":{"login":"camflan","id":27292,"avatar_url":"https://avatars0.githubusercontent.com/u/27292?v=4","gravatar_id":"","url":"https://api.github.com/users/camflan","html_url":"https://github.com/camflan","followers_url":"https://api.github.com/users/camflan/followers","following_url":"https://api.github.com/users/camflan/following{/other_user}","gists_url":"https://api.github.com/users/camflan/gists{/gist_id}","starred_url":"https://api.github.com/users/camflan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camflan/subscriptions","organizations_url":"https://api.github.com/users/camflan/orgs","repos_url":"https://api.github.com/users/camflan/repos","events_url":"https://api.github.com/users/camflan/events{/privacy}","received_events_url":"https://api.github.com/users/camflan/received_events","type":"User","site_admin":false},"created_at":"2018-05-15T16:53:32Z","updated_at":"2018-05-15T16:53:32Z","author_association":"NONE","body":"Also curious"}}
{"actor":{"display_login":"camflan"}}