sdy

add pubsub

import { prisma, isAuthenticated } from "../../../utils";
import { NEW_MESSAGE } from "../../../topics";
export default {
Mutation: {
createMessage: async (_, args, { request }) => {
createMessage: async (_, args, { request, pubsub }) => {
isAuthenticated(request);
const { user } = request;
const { message, roomId } = args;
......@@ -46,6 +47,11 @@ export default {
} else {
throw new Error("There is no room");
}
if (messageObj !== undefined) {
pubsub.publish(NEW_MESSAGE, { subMessage: messageObj });
}
return messageObj;
},
},
......