```export const CommentSubscription = subscription...
# orm-help
r
Copy code
export const CommentSubscription = subscriptionField('newComment', {
    type: 'Comment',
    description: 'New Comment Subscription',
    args: { recipeId: intArg({ required: true }) },
    subscribe: withFilter(
        (parent, args, { pubsub }, info) => pubsub.asyncIterator('newComment'),
        async (payload, variables) => {
            return payload.newComment.recipeId === variables.recipeId
        }),
    resolve: payload => payload.newComment
})
a
I was very much in you situation
Do you have an authentication middleware that tries to access the headers from the express req?
With websockets, there are no headers, so you have to validate that it exists
An example from my project:
Copy code
async function authenticate(ctx) {
  const { req, connection } = ctx;

  // For WS
  if (connection) {
    return connection.context;
  }

  const Authorization = req.get('Authorization');
  if (Authorization) {
    const token = Authorization.replace('Bearer ', '');
    return getUser(token);
  }
}
r
Thanks Alex, I am not using any middleware currently, I'll have to look into that.
r
Hey @Rushi Arumalla 👋 Is it possible for you to share any code-snippet of that file so that I can replicate it from my end? Also what library have you used for subscriptions?
r
@Alex Vilchis Finally got it working, thank you, I had to configure my onConnect correctly to have the same context , thank you again
@Ryan Thanks for reaching out, it was an error on my end, not giving my subscription the proper context
a
That’s great to hear. Now I am struggling with SSL for the production environment 🙃