Integration tests for graphql subscribers
How can I pass the publish / subscribe testing of my graphql schema without using apollo?
Can I just do this with subscriptions-transport-ws? My SubscriptionServer is configured with default settings, I can see the publishing going by simply calling a mutation request with graphql. I have established a connection to the website using my express server
const WebSocket = require('ws');
const myServer = require('../../bin/www');
const wsServer = new WebSocket.Server({
server: myServer
});
const client = new SubscriptionClient(`ws://localhost:3000/subscriptions`, {}, WebSocket);
client.subscribe(
{
query: `subscription roomSubscription(placeId: "someid") {
user {
id,
name
}
}`,
},
(error, result) => {
console.log({error, result});
}
);
const query = `
mutation {
roomAddOrUpdate(placeId: "some id") {
user {
name
}
}
}`;
const result = await graphql(schema, query, {}, req);
nothing seems to be comforting about the client.subscribe function, not sure if I will go this correct path. You can see my setup here https://github.com/farzd/firstsight/blob/master/bin/www
+3
source to share
No one has answered this question yet
Check out similar questions: