Skip to content

Instantly share code, notes, and snippets.

@gorbypark
gorbypark / simple-vue-apollo-subscription.vue
Last active August 14, 2021 11:47
A simple vue-apollo subscription example
<!--
This is a simple vue single file component example of using a subscription with vue-apollo.
This starts out as a query, and then if there are any changes to the underlying data,
the subscription updates it. The subscription works by holding open a websocket connection
to the GraphQL server. This was tested using Hasura.io and PostgreSQL, but should work with
any GraphQL implementation that supports websocket subscriptions. In the example, the
PostgreSQL table would be in a schema named "myschema" and a table named
"mytable" and that table would have two columns, "id" and "name".
-->