Internal error occurred during message handling. Please check your implementation. Error: Subscription field must return Async Iterable. Received: undefined. #1101
Hi 👋
This repo is about the GraphQL spec itself. For questions about subscriptions and how to use different libraries, try out the GraphQL discord, you should have more luck there.
+resolver
dotenv.config({ path: "../config.env" });
const pubsub = new PostgresPubSub({ connectionString: process.env.DATABASE_URL, // Make sure this environment variable is set correctly });
const USER_ADDED_TOPIC = 'userAdded';
// Subscription resolver const Subscription = { userAdded: { subscribe: () => pubsub.asyncIterator(USER_ADDED_TOPIC),
}, };
// Helper function to publish events async function publishUserAdded(newUser) { try { await pubsub.publish(USER_ADDED_TOPIC, { userAdded: newUser }); } catch (err) { console.error('Error publishing userAdded event:', err); } }
module.exports = { Subscription, publishUserAdded, };
when i run test in client vue3 cli it say Error: Socket closed with event 4500 Subscription field must return Async Iterable. Received: undefined.