docs: apollo-link-state

This commit is contained in:
Guillaume Chau
2018-05-11 16:17:40 +02:00
committed by GitHub
parent cabac36295
commit 2d3503e2c7
+35
View File
@@ -52,6 +52,7 @@ Integrates [apollo](https://www.apollographql.com/) in your [Vue](http://vuejs.o
- [Query Components](#query-components)
- [Mutation Components](#mutation-components)
- [Server-Side Rendering](#server-side-rendering)
- [Local state](#local-state)
- [Migration](#migration)
- [API Reference](#api-reference)
@@ -1656,6 +1657,40 @@ router.onReady(() => {
})
```
## Local state
If you need to manage local data, you can do so with [apollo-link-state](https://github.com/apollographql/apollo-link-state) and the `@client` directive:
```js
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!'
}
})
}
}
```
[Example project](https://codesandbox.io/s/zqqj82396p) (thx @chriswingler)
---
# Migration