Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion packages/docs/src/guide/apollo/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ this.$watch(() => this.type, (type, oldType) => {

::: danger
If you want to update a query with the result of the subscription, use `subscribeToMore`.
The methods below are suitable for a 'notify' use case
The methods below are suitable for a 'notify' use case.
:::

You can declare [Smart Subscriptions](../../api/smart-subscription.md) in the `apollo` option with the `$subscribe` keyword:
Expand Down Expand Up @@ -217,6 +217,33 @@ You can then access the subscription with `this.$apollo.subscriptions.<name>`.
Just like for queries, you can declare the subscription [with a function](./queries.md#option-function), and you can declare the `query` option [with a reactive function](./queries.md#reactive-query-definition).
:::

When server supports live queries and uses subscriptions to update them, like [Hasura](https://hasura.io/), you can
use simple subscriptions for reactive queries:

```js
data () {
return {
tags: [],
};
},
apollo: {
$subscribe: {
tags: {
query: gql`subscription {
tags {
id
label
type
}
}`,
result ({ data }) {
this.tags = data.tags;
},
},
},
},
```

## Skipping the subscription

If the subscription is skipped, it will disable it and it will not be updated anymore. You can use the `skip` option:
Expand Down