Local state

If you need to manage local data, you can do so with apollo-link-state and the @client directive:

export default {
  apollo: {
    hello: gql`
      query {
        hello @client {
          msg
        }
      }
    `
  },
  mounted() {
    // mutate the hello message
    this.$apollo
      .mutate({
        mutation: gql`
          mutation($msg: String!) {
            updateHello(message: $msg) @client
          }
        `,
        variables: {
          msg: 'hello from link-state!'
        }
      })
  }
}

This is an increasly popular way of managing client-side state. Some projects even use it as a replacement of Vuex (or other Flux-inspired solutions).

Examples


Last Updated: 11/8/2018, 5:40:45 PM