Rushi Arumalla
05/01/2020, 3:23 AMexport 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
})
Alex Vilchis
05/01/2020, 3:43 AMAlex Vilchis
05/01/2020, 3:44 AMAlex Vilchis
05/01/2020, 3:44 AMAlex Vilchis
05/01/2020, 3:45 AMasync 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);
}
}
Rushi Arumalla
05/01/2020, 5:15 AMRyan
05/01/2020, 8:55 AMRushi Arumalla
05/01/2020, 3:17 PMRushi Arumalla
05/01/2020, 3:22 PMAlex Vilchis
05/01/2020, 3:47 PM