3739a7c029
* Add Apollo boost * Add example for apollo-link-state
37 lines
747 B
Markdown
37 lines
747 B
Markdown
# 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)
|
|
[Todo App](https://codesandbox.io/s/x2jr96r8pp) (thx @NikkitaFTW)
|
|
|
|
---
|