apollographql / subscriptions-transport-ws

:arrows_clockwise: A WebSocket client + server for GraphQL subscriptions
https://www.npmjs.com/package/subscriptions-transport-ws
MIT License
1.52k stars 342 forks source link

executor is not a function #801

Closed Prady2006 closed 2 years ago

Prady2006 commented 4 years ago

const express = require("express"); const session = require("express-session"); const router = require("./routes"); const MongoDBStore = require("connect-mongodb-session")(session); const subscribe = require('./gql_schema/subscription') ; const schema = require('./gql_schema/schema'); // Initialize Firebase and MongoDB require("./config/mongoose"); require("./config/firebase"); const app = express(); const port = process.env.PORT || 8080; // const server = require('http').Server(app); // const ws = require('ws'); // const server = new ws.Server({app}); const server = require('http').createServer(app); const {SubscriptionServer} = require('subscriptions-transport-ws'); // const {Executor} = require('@graphql-tools/delegate'); const {execute} =require('graphql')

app.use(express.json());

if (!process.env.NODE_PROD_FLAG) { app.use( session({ secret: "failtell-development-secret", key: "failtell-development-key", resave: false, saveUninitialized: true, }) ); } else { const store = new MongoDBStore({ uri: process.env.MONGO_URL || "", collection: "sessionCacheStore", expires: 1000 60 60 24 5, connectionOptions: { useNewUrlParser: true, useUnifiedTopology: true, poolSize: 100, serverSelectionTimeoutMS: 10000, }, }); store.on("error", function (error) { }); app.use( session({ secret: process.env.SESSION_SECRET, key: process.env.SESSION_KEY, cookie: { maxAge: 1000 60 60 24 1, }, store: store, resave: true, saveUninitialized: true, }) ); }

app.use(router); console.log("***"); // console.log("((((((((((((((",execute); server.listen(port,(err)=>{ if(err){ console.log('error in running websocket server'); } const subsServer = new SubscriptionServer({ execute, subscribe:subscribe, schema, },{ server, // server: server, path: '/data', }) console.log('subsServer : ',subsServer); console.log('server for web socket started '); console.info(Express Server Started on Port ${port}); });

// app.listen(port, function (err) { // if (err) { // console.error(new Error(| App | Express Server Error on Port ${port}), err); // }

// console.info(| App | Express Server Started on Port ${port}); // // console.log(Subscriptions are running on ${wsUri}); // });

module.exports = app;

Graphql playground throws error when using subscriptions