{"action":"created","issue":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/350","repository_url":"https://api.github.com/repos/apollostack/apollo-client","labels_url":"https://api.github.com/repos/apollostack/apollo-client/issues/350/labels{/name}","comments_url":"https://api.github.com/repos/apollostack/apollo-client/issues/350/comments","events_url":"https://api.github.com/repos/apollostack/apollo-client/issues/350/events","html_url":"https://github.com/apollostack/apollo-client/pull/350","id":163472034,"number":350,"title":"[WIP] Fetch more / Infinite Scroll","user":{"login":"rricard","id":246520,"avatar_url":"https://avatars.githubusercontent.com/u/246520?v=3","gravatar_id":"","url":"https://api.github.com/users/rricard","html_url":"https://github.com/rricard","followers_url":"https://api.github.com/users/rricard/followers","following_url":"https://api.github.com/users/rricard/following{/other_user}","gists_url":"https://api.github.com/users/rricard/gists{/gist_id}","starred_url":"https://api.github.com/users/rricard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rricard/subscriptions","organizations_url":"https://api.github.com/users/rricard/orgs","repos_url":"https://api.github.com/users/rricard/repos","events_url":"https://api.github.com/users/rricard/events{/privacy}","received_events_url":"https://api.github.com/users/rricard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/apollostack/apollo-client/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":45,"created_at":"2016-07-01T20:50:55Z","updated_at":"2016-07-07T16:03:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apollostack/apollo-client/pulls/350","html_url":"https://github.com/apollostack/apollo-client/pull/350","diff_url":"https://github.com/apollostack/apollo-client/pull/350.diff","patch_url":"https://github.com/apollostack/apollo-client/pull/350.patch"},"body":"Adds a fetchMore method able to fetch new data and concatenate it into the store, performing, that way, an infinite scroll behavior!\r\n\r\nTODO:\r\n\r\n- [x] Update CHANGELOG.md with your change\r\n- [x] Make sure all of the significant new logic is covered by tests\r\n- [x] Rebase your changes on master so that they can be merged easily\r\n- [x] Make sure all tests and linter rules pass\r\n\r\n- [x] change `concatPaths: Array<string>` to `paginationParameters: Array<string>`, that way suppressing for special paths those parameters from the store ids. (ex: instead of `ROOT_QUERY.allPosts({cursor: 'x', type: 'y'})`, if `paginationParameters: {'ROOT_QUERY.allPosts': ['cursor']}` is set, it will only be `ROOT_QUERY.allPosts({type: 'y'})`\r\n- [x] Implement correct resolution of paths\r\n- [x] Squash!\r\n- [x] `paginationParameters` => `quietArguments`\r\n- [x] Backwards concat possible\r\n- [x] Add directive for pagination !\r\n- [x] Add a per-directive merge option\r\n- [x] Add a directive selection in the fetch more to avoid fetching more of everything\r\n- [x] fetch more can override query-level opts\r\n- [x] embed into the directive common merging use cases: `append/prepend/sort`\r\n- [x] Make sure is correctly wired (`fetchMore()` to the public API, `paginationParameters` everytime there is some store access & `fetchMore everytime we're doing a query)\r\n- [x] Do a proper system to handle directives (right now it's clearly hacky) => **REFACTOR!**\r\n- [x] So do MORE TESTS and/or integrate with existing tests to take `paginationParameters` in account.\r\n- [x] Directive removal before sending the query to the server! *OR* PR on the server to support the directive there (by adding it to the schema! Maybe somewhere in `graphql-tools`)\r\n- [ ] Add it to the docs!\r\n\r\n## Basic usage example:\r\n\r\n```js\r\nlet latest_name = null;\r\nconst subscription = client.watchQuery({\r\n  query: gql`\r\n    all_people(latest_name: $latest_name, type: $type) @apolloFetchMore {\r\n       name\r\n    }\r\n  `,\r\n  quietArguments: ['latest_name'],\r\n  variables: {\r\n    type: 'Jedi',\r\n    latest_name: null,\r\n  },\r\n}).subscribe({\r\n  next(result) {\r\n    console.log(result);\r\n    // First value => {all_people: [{name: 'Luke SkyWalker'}]}\r\n    // Second value => {all_people: [{name: 'Luke SkyWalker'}, {name: 'Obi-Wan Kenobi'}]}\r\n    const new_latest_name = result.all_people[result.all_people.length -1];\r\n    if(new_latest_name !== latest_name) {\r\n      latest_name = new_latest_name;\r\n      subscription.refetchMore({latest_name});\r\n    }\r\n  }\r\n});\r\n```\r\n\r\n## Advanced usage example:\r\n\r\n```js\r\nlet latest_name = null;\r\nconst subscription = client.watchQuery({\r\n  query: gql`\r\n    messages(cursor: $chatCur) @apolloFetchMore(name: \"messages\") {\r\n      content\r\n      replies @apolloFetchMore(name: \"replies\") {\r\n         content\r\n       }\r\n    }\r\n  `,\r\n  quietArguments: ['cursor'],\r\n  variables: {\r\n    chatCur: null,\r\n  },\r\n  mergeResults: {\r\n    messages: (oldArr, newArr) => [].concat(newArr, oldArr),\r\n  }\r\n}).subscribe({\r\n  next(result) {\r\n    console.log(result);\r\n    setTimeout(() => {\r\n      subscription.refetchMore({targetedFetchMoreDirectives: ['replies']});\r\n    }, 60000);\r\n    setTimeout(() => {\r\n      subscription.refetchMore({targetedFetchMoreDirectives: ['messages']});\r\n    }, 10000);\r\n  }\r\n});\r\n```\r\n\r\n\r\n## Advanced usage example with directives only!:\r\n\r\n```js\r\nlet latest_name = null;\r\nconst subscription = client.watchQuery({\r\n  query: gql`\r\n    messages(cursor: $chatCur) @apolloFetchMore(name: \"messages\", quiet: \"cursor\", prepend: true) {\r\n      content\r\n      replies @apolloFetchMore(name: \"replies\") {\r\n         content\r\n       }\r\n    }\r\n  `,\r\n  variables: {\r\n    chatCur: null,\r\n  },\r\n}).subscribe({\r\n  next(result) {\r\n    console.log(result);\r\n    setTimeout(() => {\r\n      subscription.refetchMore({targetedFetchMoreDirectives: ['replies']});\r\n    }, 60000);\r\n    setTimeout(() => {\r\n      subscription.refetchMore({targetedFetchMoreDirectives: ['messages']});\r\n    }, 10000);\r\n  }\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/comments/231125700","html_url":"https://github.com/apollostack/apollo-client/pull/350#issuecomment-231125700","issue_url":"https://api.github.com/repos/apollostack/apollo-client/issues/350","id":231125700,"user":{"login":"rricard","id":246520,"avatar_url":"https://avatars.githubusercontent.com/u/246520?v=3","gravatar_id":"","url":"https://api.github.com/users/rricard","html_url":"https://github.com/rricard","followers_url":"https://api.github.com/users/rricard/followers","following_url":"https://api.github.com/users/rricard/following{/other_user}","gists_url":"https://api.github.com/users/rricard/gists{/gist_id}","starred_url":"https://api.github.com/users/rricard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rricard/subscriptions","organizations_url":"https://api.github.com/users/rricard/orgs","repos_url":"https://api.github.com/users/rricard/repos","events_url":"https://api.github.com/users/rricard/events{/privacy}","received_events_url":"https://api.github.com/users/rricard/received_events","type":"User","site_admin":false},"created_at":"2016-07-07T16:03:03Z","updated_at":"2016-07-07T16:03:03Z","body":"Ok, I need to leave work so I may let you do that. I agree with what you said 👍 "}}
{"actor":{"display_login":"rricard"}}