{"action":"created","issue":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/644","repository_url":"https://api.github.com/repos/apollostack/apollo-client","labels_url":"https://api.github.com/repos/apollostack/apollo-client/issues/644/labels{/name}","comments_url":"https://api.github.com/repos/apollostack/apollo-client/issues/644/comments","events_url":"https://api.github.com/repos/apollostack/apollo-client/issues/644/events","html_url":"https://github.com/apollostack/apollo-client/issues/644","id":176704214,"number":644,"title":"Ideas for additional subscription APIs","user":{"login":"stubailo","id":448783,"avatar_url":"https://avatars.githubusercontent.com/u/448783?v=3","gravatar_id":"","url":"https://api.github.com/users/stubailo","html_url":"https://github.com/stubailo","followers_url":"https://api.github.com/users/stubailo/followers","following_url":"https://api.github.com/users/stubailo/following{/other_user}","gists_url":"https://api.github.com/users/stubailo/gists{/gist_id}","starred_url":"https://api.github.com/users/stubailo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stubailo/subscriptions","organizations_url":"https://api.github.com/users/stubailo/orgs","repos_url":"https://api.github.com/users/stubailo/repos","events_url":"https://api.github.com/users/stubailo/events{/privacy}","received_events_url":"https://api.github.com/users/stubailo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/apollostack/apollo-client/labels/feature","name":"feature","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":28,"created_at":"2016-09-13T17:41:43Z","updated_at":"2016-09-16T00:42:28Z","closed_at":null,"body":"Yesterday, we published all of the pieces of the initial Apollo GraphQL subscriptions implementation. Read about it here: https://medium.com/apollo-stack/graphql-subscriptions-in-apollo-client-9a2457f015fb#.qd8rnff9d\r\n\r\nRight now, the API looks like this:\r\n\r\n```js\r\nclient.subscribe({ query, variables }) => Observable\r\n```\r\n\r\nIt's the most basic thing we could come up with, and makes sense for an initial release. This API is good if what you need is a stream of events, and it's an API we can build on top of to enable other features. But it's definitely not the final thing we want, because it doesn't help developers display those subscription results in your UI.\r\n\r\nHere are some ideas for additional APIs we can build on top of the base:\r\n\r\n### fetchMore-style subscription\r\n\r\nIn the [GitHunt UI](https://github.com/apollostack/GitHunt-React/pull/87/files), we use a subscription to update the result of the original comments query. We think this is going to be a common pattern.\r\n\r\nIn usage, this is very similar to [fetchMore](http://dev.apollodata.com/react/pagination.html), where you do a second query to update the results of the first. But in this case, the second query will be a subscription, and it will get multiple results. You can think of it as reactive pagination.\r\n\r\nSo one proposed API addition is to add a method to ObservableQuery, called something like `subscribeToMore`, that has an `updateQuery` reducer just like the `fetchMore` query does.\r\n\r\n### mutation-style subscription\r\n\r\nYou can think of subscriptions as \"someone else's mutation result\". In that context, it makes sense to have all of the same features as mutations, and perhaps even reuse the same code. So we should have all of the ways you can [use mutation results](http://dev.apollodata.com/react/cache-updates.html):\r\n\r\n1. Updating objects by matching up IDs\r\n2. `updateQueries`, so that you can reuse your mutation reducers in your subscription results.\r\n3. `refetchQueries`, so that subscriptions can trigger page refetches\r\n\r\nI'm not sure what the API for this would look like, but open to suggestions.\r\n\r\nAnd if anyone else has ideas, let's talk!"},"comment":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/comments/247492690","html_url":"https://github.com/apollostack/apollo-client/issues/644#issuecomment-247492690","issue_url":"https://api.github.com/repos/apollostack/apollo-client/issues/644","id":247492690,"user":{"login":"tmeasday","id":132554,"avatar_url":"https://avatars.githubusercontent.com/u/132554?v=3","gravatar_id":"","url":"https://api.github.com/users/tmeasday","html_url":"https://github.com/tmeasday","followers_url":"https://api.github.com/users/tmeasday/followers","following_url":"https://api.github.com/users/tmeasday/following{/other_user}","gists_url":"https://api.github.com/users/tmeasday/gists{/gist_id}","starred_url":"https://api.github.com/users/tmeasday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmeasday/subscriptions","organizations_url":"https://api.github.com/users/tmeasday/orgs","repos_url":"https://api.github.com/users/tmeasday/repos","events_url":"https://api.github.com/users/tmeasday/events{/privacy}","received_events_url":"https://api.github.com/users/tmeasday/received_events","type":"User","site_admin":false},"created_at":"2016-09-16T00:42:28Z","updated_at":"2016-09-16T00:42:28Z","body":"I guess it's easy to add layers of sugar later anyway."}}
{"actor":{"display_login":"tmeasday"}}