Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for GraphQL subscriptions to support callbacks such as 'userStreamAdded' #3

Open
gouldingken opened this issue Feb 13, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@gouldingken
Copy link
Member

https://www.apollographql.com/docs/react/data/subscriptions/

Reference TheMain.vue for an example use case we would want to replicate.

apollo: {
    $subscribe: {
      userStreamAdded: {
        query: gql`
          subscription userStreamAdded {
            userStreamAdded
          }
        `,
        result({ data }) {
          if (!data || !data.userStreamAdded) return
          if (this.$route.params.streamId === data.userStreamAdded.id) return
          this.$eventHub.$emit('notification', {
            text: `You've got a new stream!`,
            action: {
              name: 'View Stream',
              to: `/streams/${data.userStreamAdded.id}`
            }
          })
        },
        skip() {
          return !this.isLoggedIn
        }
      }
    }
  },
@gouldingken gouldingken added the enhancement New feature or request label Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant