{"action":"created","comment":{"url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/comments/115455642","pull_request_review_id":36991617,"id":115455642,"diff_hunk":"@@ -1,20 +1,79 @@\n+import { TypeKind } from 'graphql';\n import isNotGraphqlPrivateType from '../isNotGraphqlPrivateType';\n \n-export default (resource, type, { excludeFields }) =>\n-    resource.fields\n+export const isSubObject = field => {\n+    if (\n+        field.type.kind === TypeKind.OBJECT ||\n+        (field.type.kind === TypeKind.LIST &&\n+            (field.type.ofType.kind === TypeKind.OBJECT || field.type.ofType.kind === TypeKind.LIST)) ||\n+        (field.type.kind === TypeKind.NON_NULL &&\n+            (field.type.ofType.kind === TypeKind.OBJECT || field.type.ofType.kind === TypeKind.LIST))\n+    ) {\n+        return true;\n+    }\n+\n+    return false;\n+};\n+\n+const isExcludedFieldFactory = (resource, verbType, excludeFields) => field => {\n+    if (excludeFields) {\n+        if (Array.isArray(excludeFields)) {\n+            return excludeFields.includes(field.name);\n+        }\n+\n+        if (typeof excludeFields === 'function') {\n+            return excludeFields(field, resource, verbType);\n+        }\n+    }\n+\n+    return false;\n+};\n+\n+export const buildFieldListFromList = (resource, fields, verbType, resources, types, options) => {\n+    const { excludeFields, ignoreSubObjects, ignoreSubResources } = options;\n+    const isExcludedField = isExcludedFieldFactory(resource, verbType, excludeFields);\n+\n+    return fields\n         .filter(isNotGraphqlPrivateType)\n-        .filter(field => {\n-            if (excludeFields) {\n-                if (Array.isArray(excludeFields)) {\n-                    return !excludeFields.includes(field.name);\n+        .map(field => {\n+            if (isExcludedField(field)) {\n+                return false;","path":"src/introspection/buildQueriesForResource/buildFieldList.js","position":46,"original_position":46,"commit_id":"4f341c98b580154130982cd068df7e3863c3fcd0","original_commit_id":"4f341c98b580154130982cd068df7e3863c3fcd0","user":{"login":"ThieryMichel","id":4034399,"avatar_url":"https://avatars1.githubusercontent.com/u/4034399?v=3","gravatar_id":"","url":"https://api.github.com/users/ThieryMichel","html_url":"https://github.com/ThieryMichel","followers_url":"https://api.github.com/users/ThieryMichel/followers","following_url":"https://api.github.com/users/ThieryMichel/following{/other_user}","gists_url":"https://api.github.com/users/ThieryMichel/gists{/gist_id}","starred_url":"https://api.github.com/users/ThieryMichel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThieryMichel/subscriptions","organizations_url":"https://api.github.com/users/ThieryMichel/orgs","repos_url":"https://api.github.com/users/ThieryMichel/repos","events_url":"https://api.github.com/users/ThieryMichel/events{/privacy}","received_events_url":"https://api.github.com/users/ThieryMichel/received_events","type":"User","site_admin":false},"body":"why returning false in a map, why not filter out directly ?","created_at":"2017-05-09T10:22:59Z","updated_at":"2017-05-09T10:25:36Z","html_url":"https://github.com/marmelab/aor-simple-graphql-client/pull/33#discussion_r115455642","pull_request_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/33","_links":{"self":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/comments/115455642"},"html":{"href":"https://github.com/marmelab/aor-simple-graphql-client/pull/33#discussion_r115455642"},"pull_request":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/33","id":119196147,"html_url":"https://github.com/marmelab/aor-simple-graphql-client/pull/33","diff_url":"https://github.com/marmelab/aor-simple-graphql-client/pull/33.diff","patch_url":"https://github.com/marmelab/aor-simple-graphql-client/pull/33.patch","issue_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues/33","number":33,"state":"open","locked":false,"title":"[RFR] Ability to include sub objects and sub resources","user":{"login":"djhi","id":1122076,"avatar_url":"https://avatars1.githubusercontent.com/u/1122076?v=3","gravatar_id":"","url":"https://api.github.com/users/djhi","html_url":"https://github.com/djhi","followers_url":"https://api.github.com/users/djhi/followers","following_url":"https://api.github.com/users/djhi/following{/other_user}","gists_url":"https://api.github.com/users/djhi/gists{/gist_id}","starred_url":"https://api.github.com/users/djhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djhi/subscriptions","organizations_url":"https://api.github.com/users/djhi/orgs","repos_url":"https://api.github.com/users/djhi/repos","events_url":"https://api.github.com/users/djhi/events{/privacy}","received_events_url":"https://api.github.com/users/djhi/received_events","type":"User","site_admin":false},"body":"Follow #32 \r\n\r\nFixes #30 ","created_at":"2017-05-05T15:07:38Z","updated_at":"2017-05-09T10:25:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c3c2669ee9bf6374500280b7232d364d8e3da5d1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/33/commits","review_comments_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/33/comments","review_comment_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues/33/comments","statuses_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/statuses/4f341c98b580154130982cd068df7e3863c3fcd0","head":{"label":"marmelab:embedded_objects","ref":"embedded_objects","sha":"4f341c98b580154130982cd068df7e3863c3fcd0","user":{"login":"marmelab","id":3116319,"avatar_url":"https://avatars2.githubusercontent.com/u/3116319?v=3","gravatar_id":"","url":"https://api.github.com/users/marmelab","html_url":"https://github.com/marmelab","followers_url":"https://api.github.com/users/marmelab/followers","following_url":"https://api.github.com/users/marmelab/following{/other_user}","gists_url":"https://api.github.com/users/marmelab/gists{/gist_id}","starred_url":"https://api.github.com/users/marmelab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmelab/subscriptions","organizations_url":"https://api.github.com/users/marmelab/orgs","repos_url":"https://api.github.com/users/marmelab/repos","events_url":"https://api.github.com/users/marmelab/events{/privacy}","received_events_url":"https://api.github.com/users/marmelab/received_events","type":"Organization","site_admin":false},"repo":{"id":81747912,"name":"aor-simple-graphql-client","full_name":"marmelab/aor-simple-graphql-client","owner":{"login":"marmelab","id":3116319,"avatar_url":"https://avatars2.githubusercontent.com/u/3116319?v=3","gravatar_id":"","url":"https://api.github.com/users/marmelab","html_url":"https://github.com/marmelab","followers_url":"https://api.github.com/users/marmelab/followers","following_url":"https://api.github.com/users/marmelab/following{/other_user}","gists_url":"https://api.github.com/users/marmelab/gists{/gist_id}","starred_url":"https://api.github.com/users/marmelab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmelab/subscriptions","organizations_url":"https://api.github.com/users/marmelab/orgs","repos_url":"https://api.github.com/users/marmelab/repos","events_url":"https://api.github.com/users/marmelab/events{/privacy}","received_events_url":"https://api.github.com/users/marmelab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/marmelab/aor-simple-graphql-client","description":"A simple GraphQL client for admin-on-rest","fork":false,"url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client","forks_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/forks","keys_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/teams","hooks_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/hooks","issue_events_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues/events{/number}","events_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/events","assignees_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/assignees{/user}","branches_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/branches{/branch}","tags_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/tags","blobs_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/statuses/{sha}","languages_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/languages","stargazers_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/stargazers","contributors_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/contributors","subscribers_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/subscribers","subscription_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/subscription","commits_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/contents/{+path}","compare_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/merges","archive_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/downloads","issues_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues{/number}","pulls_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls{/number}","milestones_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/milestones{/number}","notifications_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/labels{/name}","releases_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/releases{/id}","deployments_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/deployments","created_at":"2017-02-12T18:40:05Z","updated_at":"2017-05-04T23:34:25Z","pushed_at":"2017-05-06T16:42:05Z","git_url":"git://github.com/marmelab/aor-simple-graphql-client.git","ssh_url":"git@github.com:marmelab/aor-simple-graphql-client.git","clone_url":"https://github.com/marmelab/aor-simple-graphql-client.git","svn_url":"https://github.com/marmelab/aor-simple-graphql-client","homepage":null,"size":234,"stargazers_count":15,"watchers_count":15,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":15,"default_branch":"master"}},"base":{"label":"marmelab:master","ref":"master","sha":"2fc1a25af008cea5cf9e77650ab6844d7978a0cd","user":{"login":"marmelab","id":3116319,"avatar_url":"https://avatars2.githubusercontent.com/u/3116319?v=3","gravatar_id":"","url":"https://api.github.com/users/marmelab","html_url":"https://github.com/marmelab","followers_url":"https://api.github.com/users/marmelab/followers","following_url":"https://api.github.com/users/marmelab/following{/other_user}","gists_url":"https://api.github.com/users/marmelab/gists{/gist_id}","starred_url":"https://api.github.com/users/marmelab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmelab/subscriptions","organizations_url":"https://api.github.com/users/marmelab/orgs","repos_url":"https://api.github.com/users/marmelab/repos","events_url":"https://api.github.com/users/marmelab/events{/privacy}","received_events_url":"https://api.github.com/users/marmelab/received_events","type":"Organization","site_admin":false},"repo":{"id":81747912,"name":"aor-simple-graphql-client","full_name":"marmelab/aor-simple-graphql-client","owner":{"login":"marmelab","id":3116319,"avatar_url":"https://avatars2.githubusercontent.com/u/3116319?v=3","gravatar_id":"","url":"https://api.github.com/users/marmelab","html_url":"https://github.com/marmelab","followers_url":"https://api.github.com/users/marmelab/followers","following_url":"https://api.github.com/users/marmelab/following{/other_user}","gists_url":"https://api.github.com/users/marmelab/gists{/gist_id}","starred_url":"https://api.github.com/users/marmelab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmelab/subscriptions","organizations_url":"https://api.github.com/users/marmelab/orgs","repos_url":"https://api.github.com/users/marmelab/repos","events_url":"https://api.github.com/users/marmelab/events{/privacy}","received_events_url":"https://api.github.com/users/marmelab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/marmelab/aor-simple-graphql-client","description":"A simple GraphQL client for admin-on-rest","fork":false,"url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client","forks_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/forks","keys_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/teams","hooks_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/hooks","issue_events_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues/events{/number}","events_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/events","assignees_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/assignees{/user}","branches_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/branches{/branch}","tags_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/tags","blobs_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/statuses/{sha}","languages_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/languages","stargazers_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/stargazers","contributors_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/contributors","subscribers_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/subscribers","subscription_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/subscription","commits_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/contents/{+path}","compare_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/merges","archive_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/downloads","issues_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues{/number}","pulls_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls{/number}","milestones_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/milestones{/number}","notifications_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/labels{/name}","releases_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/releases{/id}","deployments_url":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/deployments","created_at":"2017-02-12T18:40:05Z","updated_at":"2017-05-04T23:34:25Z","pushed_at":"2017-05-06T16:42:05Z","git_url":"git://github.com/marmelab/aor-simple-graphql-client.git","ssh_url":"git@github.com:marmelab/aor-simple-graphql-client.git","clone_url":"https://github.com/marmelab/aor-simple-graphql-client.git","svn_url":"https://github.com/marmelab/aor-simple-graphql-client","homepage":null,"size":234,"stargazers_count":15,"watchers_count":15,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/33"},"html":{"href":"https://github.com/marmelab/aor-simple-graphql-client/pull/33"},"issue":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues/33"},"comments":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/marmelab/aor-simple-graphql-client/statuses/4f341c98b580154130982cd068df7e3863c3fcd0"}}}}
{"actor":{"display_login":"ThieryMichel"}}