'Apollo Subscription PubSub not triggering Listener

Working getting subscriptions working in apollo. I have my web socket set up properly, and I can see that I'm connecting, as I see it flow into the pubsub module. Though I think something is up with how I subscribing, as the server is not triggering a response when I publish.

Apologize for any confusion around naming, as I'm using it for something called subscriptions.

Graphql Subscription

  subscription subscriptionsUpdated($userId: String!){
    subscriptionsUpdated(user: $userId, type:ROOM, open:true) {
        id,
        parent{
          ... on Rooms{
            id
          }
        }
    }
  }

GraphQLType

  subscription: new GraphQLObjectType({
    name: `subscriptions`,
    fields: {
      subscriptionsUpdated:{
        type:Subscriptions.type,
        args:{
          parent: { type: GraphQLString},
          type:{ type: ContentTypes },
          open: {type: GraphQLBoolean },
          user:{type: GraphQLString },
        },
        resolve:(source, args)=>{
          console.log('it worked and stuff');
          return {};
        }
      },
    }
  })

Susbscription Manager and setup functions:

import schema from '../graphql/index.js';
const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub,
  setupFunctions: {
    subscriptionsUpdated: (options, args) => ({
      subscriptionsUpdated: (comment)=>{
        return true;
      },
    }),
  },
});

In My Mutation (I can see this firing)

pubsub.publish('subscriptionsUpdated', doc);

With the event firing, shouldn't the subscriptionsUpdated resolve function / or the setup function fire?

I've looked into the githunt examples and medium post on the topic, but still struggling to get this last part working.

Any help or insight would be awesome!



Solution 1:[1]

I wish I had a better answer on how I solved my issue. I've been tweaking things and I'm not sure what I did to make it work. Meh... :/

Though if you do get stuck somewhere along this way, dive into the graphql subscriptions package. You'll at least have a better idea of how things move.

If your connected properly your browser will respond with any other errors you're experiencing. Hope his helps! Safe journeys!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Justin