Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

useSubscription doesn't work for new windows #4016

Open
developdeez opened this issue Jun 9, 2020 · 0 comments
Open

useSubscription doesn't work for new windows #4016

developdeez opened this issue Jun 9, 2020 · 0 comments

Comments

@developdeez
Copy link

Hello

This is my first time using useSub and I noticed that although my backend sends it's responses to the client. The client using useSub doesn't do anything. I usually use subscribeToMore with query, but for this job I want to only get the most updated info. Is there a way to check if useSub connects correctly? Or is it broken in "@apollo/react-hooks": "^3.1.3"

Client

  const { data, loading } = useSubscription(INCOMING_VIDEO_CHAT, {
    onSubscriptionData: ({  subscriptionData }) => {
      console.log(subscriptionData);
    }
  });

Server:

module.exports = {
  type: chatInfoType,
  subscribe: () => pubsub.asyncIterator(INCOMING_VIDEO_CHAT),
  async resolve(payload, { }, req) {
    if (auth.isAuthenticated(req)) {
      if (!payload) {
        return;
      }
      const { userID, rn, p } = payload;

      try {
        if (req.id === userID) {
          return { rn, p };
        } else {
          return;
        }
      } catch (e) {
        throw new Error(e);
      }
    }
  }
};
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant