{"action":"created","issue":{"url":"https://api.github.com/repos/apollographql/apollo-link-state/issues/53","repository_url":"https://api.github.com/repos/apollographql/apollo-link-state","labels_url":"https://api.github.com/repos/apollographql/apollo-link-state/issues/53/labels{/name}","comments_url":"https://api.github.com/repos/apollographql/apollo-link-state/issues/53/comments","events_url":"https://api.github.com/repos/apollographql/apollo-link-state/issues/53/events","html_url":"https://github.com/apollographql/apollo-link-state/issues/53","id":273452128,"number":53,"title":"[Feature request] Allow for invoking async stuff before doing request in graphql() HOC","user":{"login":"jbaxleyiii","id":4967600,"avatar_url":"https://avatars2.githubusercontent.com/u/4967600?v=4","gravatar_id":"","url":"https://api.github.com/users/jbaxleyiii","html_url":"https://github.com/jbaxleyiii","followers_url":"https://api.github.com/users/jbaxleyiii/followers","following_url":"https://api.github.com/users/jbaxleyiii/following{/other_user}","gists_url":"https://api.github.com/users/jbaxleyiii/gists{/gist_id}","starred_url":"https://api.github.com/users/jbaxleyiii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbaxleyiii/subscriptions","organizations_url":"https://api.github.com/users/jbaxleyiii/orgs","repos_url":"https://api.github.com/users/jbaxleyiii/repos","events_url":"https://api.github.com/users/jbaxleyiii/events{/privacy}","received_events_url":"https://api.github.com/users/jbaxleyiii/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jbaxleyiii","id":4967600,"avatar_url":"https://avatars2.githubusercontent.com/u/4967600?v=4","gravatar_id":"","url":"https://api.github.com/users/jbaxleyiii","html_url":"https://github.com/jbaxleyiii","followers_url":"https://api.github.com/users/jbaxleyiii/followers","following_url":"https://api.github.com/users/jbaxleyiii/following{/other_user}","gists_url":"https://api.github.com/users/jbaxleyiii/gists{/gist_id}","starred_url":"https://api.github.com/users/jbaxleyiii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbaxleyiii/subscriptions","organizations_url":"https://api.github.com/users/jbaxleyiii/orgs","repos_url":"https://api.github.com/users/jbaxleyiii/repos","events_url":"https://api.github.com/users/jbaxleyiii/events{/privacy}","received_events_url":"https://api.github.com/users/jbaxleyiii/received_events","type":"User","site_admin":false},"assignees":[{"login":"jbaxleyiii","id":4967600,"avatar_url":"https://avatars2.githubusercontent.com/u/4967600?v=4","gravatar_id":"","url":"https://api.github.com/users/jbaxleyiii","html_url":"https://github.com/jbaxleyiii","followers_url":"https://api.github.com/users/jbaxleyiii/followers","following_url":"https://api.github.com/users/jbaxleyiii/following{/other_user}","gists_url":"https://api.github.com/users/jbaxleyiii/gists{/gist_id}","starred_url":"https://api.github.com/users/jbaxleyiii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbaxleyiii/subscriptions","organizations_url":"https://api.github.com/users/jbaxleyiii/orgs","repos_url":"https://api.github.com/users/jbaxleyiii/repos","events_url":"https://api.github.com/users/jbaxleyiii/events{/privacy}","received_events_url":"https://api.github.com/users/jbaxleyiii/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2017-11-13T14:39:48Z","updated_at":"2017-11-13T14:40:50Z","closed_at":null,"author_association":"OWNER","body":"Hey Apollo Team,\nI've had a problem that I need to preload some data before doing main request to graphql server.\nI've solved this by using custom logic, redux, redux-saga and [config.skip](http://dev.apollodata.com/react/api-graphql.html#graphql-config-skip). Still I have to sync redux-saga and redux on server and client so process is a bit challenging.\n\nI think that this `feature request` could improve dramatically handling scenarios and especially SSR when some data or any other async action is required before making the main request to graphql server.\n\n**Example**\n\n```graphql\nquery Shops($location:Location) {\n  shops(location:$location) {\n    name\n  }\n}\n```\n\n```jsx\nimport React from 'react';\nimport { graphql } from 'react-apollo';\n\nconst App = ({ data }) => {\n  if (data.loading) {\n    return <div>Loading</div>;\n  }\n\n  if (data.error) {\n    return <div>error</div>;\n  }\n\n  return <div>{JSON.stringify(data.shops)}</div>;\n};\n\nconst config = {\n  // Container component created by graphql(query, config)(Component)\n  // is in loading state until:\n  //   - promise returned from async() resolves\n  //   - and response from graphql returns\n\n  // [NEW API]\n  // you can name it as you want\n  asyncProps(props) {\n    const { id } = props.match.params; // just as example, react-router v4\n    \n    // Mysterious API client\n    return Api.fetchLocationForShop({ id }).then((response) => {\n      // Here we return new props that will be merged with props component\n      return {\n        lat: response.data.location.lat,\n        lon: response.data.location.lon,\n      };\n    });\n  },\n  options(props) {\n    return {\n      variables: {\n        location: {\n          // Here we are using new props to setup query variable\n          lat: props.lat,\n          lon: props.lon,\n        };\n      },\n    };\n  },\n};\n\nexport default graphql(ShopsQuery, config)(App);\n```\n\nWhat do you think about that approach? Is it possible to integrate such functionality into react-apollo? The main benefit would be super easy SSR.\n\nThanks in advance!\n\n"},"comment":{"url":"https://api.github.com/repos/apollographql/apollo-link-state/issues/comments/343938905","html_url":"https://github.com/apollographql/apollo-link-state/issues/53#issuecomment-343938905","issue_url":"https://api.github.com/repos/apollographql/apollo-link-state/issues/53","id":343938905,"user":{"login":"jbaxleyiii","id":4967600,"avatar_url":"https://avatars2.githubusercontent.com/u/4967600?v=4","gravatar_id":"","url":"https://api.github.com/users/jbaxleyiii","html_url":"https://github.com/jbaxleyiii","followers_url":"https://api.github.com/users/jbaxleyiii/followers","following_url":"https://api.github.com/users/jbaxleyiii/following{/other_user}","gists_url":"https://api.github.com/users/jbaxleyiii/gists{/gist_id}","starred_url":"https://api.github.com/users/jbaxleyiii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbaxleyiii/subscriptions","organizations_url":"https://api.github.com/users/jbaxleyiii/orgs","repos_url":"https://api.github.com/users/jbaxleyiii/repos","events_url":"https://api.github.com/users/jbaxleyiii/events{/privacy}","received_events_url":"https://api.github.com/users/jbaxleyiii/received_events","type":"User","site_admin":false},"created_at":"2017-11-13T14:40:50Z","updated_at":"2017-11-13T14:40:50Z","author_association":"OWNER","body":"➤ stale[bot] commented:\n\nThis issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!\n"}}
{"actor":{"display_login":"jbaxleyiii"}}