graphile / graphile.github.io

PostGraphile (PostGraphQL) and Graphile-Build website - contributions very welcome!
https://www.graphile.org/
26 stars 127 forks source link

Vue subscriptions example #119

Open benjie opened 5 years ago

benjie commented 5 years ago
 apollo: {
    $subscribe: {
        tagAdded: {
        query: gqlsubscription test{listen(topic: "hello"){relatedNodeId}},
        // Reactive variables
        variables () {
          // This works just like regular queries
          // and will re-subscribe with the right variables
          // each time the values change
          return {
            type: this.type,
          }
        },
        // Result hook
        result (data) {
          console.log(data)
        },
      },
    },

https://discordapp.com/channels/489127045289476126/498852330754801666/560214820121739285

francoisp commented 5 years ago

thanks again for the pointer benjie, here it is with the few missing backticks, for the next guy that will paste this in and might be wondering...

apollo: {
$subscribe: {
    tagAdded: {
    query: gql`subscription {listen(topic: "hello"){relatedNodeId}}`,
    // Reactive variables
    variables () {
      // This works just like regular queries
      // and will re-subscribe with the right variables
      // each time the values change
      return {
        type: this.type,
      }
    },
    // Result hook
    result (data) {
      console.log(data)
    },
  },
},
}