{"action":"created","issue":{"url":"https://api.github.com/repos/Akryum/vue-apollo/issues/388","repository_url":"https://api.github.com/repos/Akryum/vue-apollo","labels_url":"https://api.github.com/repos/Akryum/vue-apollo/issues/388/labels{/name}","comments_url":"https://api.github.com/repos/Akryum/vue-apollo/issues/388/comments","events_url":"https://api.github.com/repos/Akryum/vue-apollo/issues/388/events","html_url":"https://github.com/Akryum/vue-apollo/issues/388","id":359713831,"node_id":"MDU6SXNzdWUzNTk3MTM4MzE=","number":388,"title":"Skip query option is  triggering a request","user":{"login":"robsontenorio","id":118955,"node_id":"MDQ6VXNlcjExODk1NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/118955?v=4","gravatar_id":"","url":"https://api.github.com/users/robsontenorio","html_url":"https://github.com/robsontenorio","followers_url":"https://api.github.com/users/robsontenorio/followers","following_url":"https://api.github.com/users/robsontenorio/following{/other_user}","gists_url":"https://api.github.com/users/robsontenorio/gists{/gist_id}","starred_url":"https://api.github.com/users/robsontenorio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robsontenorio/subscriptions","organizations_url":"https://api.github.com/users/robsontenorio/orgs","repos_url":"https://api.github.com/users/robsontenorio/repos","events_url":"https://api.github.com/users/robsontenorio/events{/privacy}","received_events_url":"https://api.github.com/users/robsontenorio/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-13T01:58:38Z","updated_at":"2018-10-25T14:19:54Z","closed_at":null,"author_association":"NONE","body":"The same page/view handles `/users/<some-id>` (edit) and `/users/add` (add) routes. \r\n\r\nSo, when some id is provided (ex `/users/99`) it will fetch the user data and works fine. But, when route is `/user/add` a request is sent to backend even with `skip` set. \r\n\r\nAm i missing something? Is something related to apollo/component life cycle?\r\n\r\n```js\r\nexport default {\r\n  apollo: {\r\n    user: {\r\n      query: findUserQuery,\r\n      variables () {\r\n        return { id: this.$route.params.id }\r\n      }\r\n    }\r\n  },\r\n  data () {\r\n    return {\r\n      user: {\r\n           posts: []\r\n           // more empty attributes in here\r\n      }\r\n    }\r\n  },\r\n  mounted () {\r\n    if (this.$route.params.id === 'add') {\r\n      // this will fetch data from backend\r\n      this.$apollo.queries.user.skip = true\r\n    }\r\n  }\r\n```"},"comment":{"url":"https://api.github.com/repos/Akryum/vue-apollo/issues/comments/433069983","html_url":"https://github.com/Akryum/vue-apollo/issues/388#issuecomment-433069983","issue_url":"https://api.github.com/repos/Akryum/vue-apollo/issues/388","id":433069983,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzA2OTk4Mw==","user":{"login":"GPrimola","id":4721118,"node_id":"MDQ6VXNlcjQ3MjExMTg=","avatar_url":"https://avatars0.githubusercontent.com/u/4721118?v=4","gravatar_id":"","url":"https://api.github.com/users/GPrimola","html_url":"https://github.com/GPrimola","followers_url":"https://api.github.com/users/GPrimola/followers","following_url":"https://api.github.com/users/GPrimola/following{/other_user}","gists_url":"https://api.github.com/users/GPrimola/gists{/gist_id}","starred_url":"https://api.github.com/users/GPrimola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPrimola/subscriptions","organizations_url":"https://api.github.com/users/GPrimola/orgs","repos_url":"https://api.github.com/users/GPrimola/repos","events_url":"https://api.github.com/users/GPrimola/events{/privacy}","received_events_url":"https://api.github.com/users/GPrimola/received_events","type":"User","site_admin":false},"created_at":"2018-10-25T14:19:54Z","updated_at":"2018-10-25T14:19:54Z","author_association":"NONE","body":"@robsontenorio I faced the same issue, but in fact you're missing something.\r\nBy the mounted lifecycle, apollo has already prepared the defied queries to be executed, so any changes in theirs variables would only take effect after que next tick.\r\n\r\nI suggest you do the following:\r\n\r\n```javascript\r\nexport default {\r\n  apollo: {\r\n    user: {\r\n      query: findUserQuery,\r\n      variables () {\r\n        return { id: this.$route.params.id }\r\n      },\r\n      skip () {\r\n        if (this.$route.params.id === 'add') {\r\n          // this will fetch data from backend\r\n          this.$apollo.queries.user.skip = true\r\n        }\r\n      }\r\n    }\r\n  },\r\n  data () {\r\n    return {\r\n      user: {\r\n           posts: []\r\n           // more empty attributes in here\r\n      }\r\n    }\r\n  }\r\n```\r\n\r\nThat should work."}}
{"actor":{"display_login":"GPrimola"}}