{"action":"created","issue":{"url":"https://api.github.com/repos/apollographql/subscriptions-transport-ws/issues/307","repository_url":"https://api.github.com/repos/apollographql/subscriptions-transport-ws","labels_url":"https://api.github.com/repos/apollographql/subscriptions-transport-ws/issues/307/labels{/name}","comments_url":"https://api.github.com/repos/apollographql/subscriptions-transport-ws/issues/307/comments","events_url":"https://api.github.com/repos/apollographql/subscriptions-transport-ws/issues/307/events","html_url":"https://github.com/apollographql/subscriptions-transport-ws/issues/307","id":278451186,"number":307,"title":"resolver subscribe doesn't seem to ever be called","user":{"login":"drFabio","id":2636143,"avatar_url":"https://avatars1.githubusercontent.com/u/2636143?v=4","gravatar_id":"","url":"https://api.github.com/users/drFabio","html_url":"https://github.com/drFabio","followers_url":"https://api.github.com/users/drFabio/followers","following_url":"https://api.github.com/users/drFabio/following{/other_user}","gists_url":"https://api.github.com/users/drFabio/gists{/gist_id}","starred_url":"https://api.github.com/users/drFabio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drFabio/subscriptions","organizations_url":"https://api.github.com/users/drFabio/orgs","repos_url":"https://api.github.com/users/drFabio/repos","events_url":"https://api.github.com/users/drFabio/events{/privacy}","received_events_url":"https://api.github.com/users/drFabio/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-01T12:26:06Z","updated_at":"2017-12-04T20:26:02Z","closed_at":"2017-12-04T20:26:02Z","author_association":"NONE","body":"Trying to use graphiql subscription with the following server, the resolve is called but the subscribe never get's called.\r\n\r\nThe intended outcome would be for the subscribe to be fired and I see the subscription result in graphiql.\r\nThe actual outcome is that the subscription in graphiql or the subscribe method are never called.\r\n\r\n```javascript\r\nconst { PubSub } = require('graphql-subscriptions')\r\nconst { SubscriptionServer } = require('subscriptions-transport-ws')\r\nconst { execute, subscribe } = require('graphql')\r\nconst { makeExecutableSchema } = require('graphql-tools')\r\nconst { graphqlExpress, graphiqlExpress } = require('apollo-server-express')\r\nconst http = require('http')\r\nconst bodyParser = require('body-parser')\r\nconst cors = require('cors')\r\nconst cookieParser = require('cookie-parser')\r\nconst session = require('express-session')\r\n\r\nconst express = require('express')\r\nconst SOMETHING_CHANGED_TOPIC = 'something_changed'\r\nconst pubsub = new PubSub()\r\nconst typeDefs = `\r\n  type Result {\r\n    id: String\r\n  }\r\n  type Subscription {\r\n    somethingChanged: Result\r\n  }\r\n  type Query {\r\n    foo: Result\r\n  }\r\n  schema {\r\n    query: Query\r\n    subscription: Subscription\r\n  }\r\n`\r\nconst resolvers = {\r\n  Query: {\r\n    foo: () => ({id: 1})\r\n  },\r\n  Subscription: {\r\n    somethingChanged: {\r\n      resolve: root => {\r\n        console.log('subscription server resolve', {root})\r\n        return root\r\n      },\r\n      subscribe: () => {\r\n       // Never fired\r\n        console.log('ON subscribe')\r\n        return pubsub.asyncIterator(SOMETHING_CHANGED_TOPIC)\r\n      }\r\n    }\r\n  }\r\n}\r\nconst schemaOptions = {\r\n  typeDefs,\r\n  resolvers\r\n}\r\nconst schema = makeExecutableSchema(schemaOptions)\r\n\r\nconst WS_PORT = process.env.WS_PORT || 4001\r\nconst websocketServer = http.createServer((request, response) => {\r\n  response.writeHead(404)\r\n  response.end()\r\n})\r\nwebsocketServer.listen(WS_PORT, (err) => {\r\n  if (err) {\r\n    throw new Error(err)\r\n  }\r\n  SubscriptionServer.create(\r\n    {\r\n      execute,\r\n      subscribe,\r\n      schema,\r\n      onConnect (params, socket) {\r\n        console.log('on connect!')\r\n        return Promise.resolve()\r\n      }\r\n    },\r\n    { server: websocketServer, path: '/subscriptions' }\r\n  )\r\n  console.log(\r\n    `App's websocket is listening on port ${websocketServer.address().port}`\r\n  )\r\n})\r\nconst app = express()\r\napp.use(cors({origin: true, credentials: true}))\r\napp.use(cookieParser())\r\napp.use('/graphql', bodyParser.json(), graphqlExpress({schema}))\r\napp.use('/graphiql', bodyParser.json(), graphiqlExpress({\r\n  endpointURL: '/graphql',\r\n  subscriptionsEndpoint: `ws://localhost:${WS_PORT}/subscriptions`\r\n}))\r\nconst port = process.env.PORT || 4000\r\nconst server = http.createServer(app)\r\nserver.listen(port, '0.0.0.0')\r\nlet id = 10\r\npubsub.subscribe(SOMETHING_CHANGED_TOPIC, (result) => {\r\n  console.log(`Received result of ${SOMETHING_CHANGED_TOPIC}`, result)\r\n})\r\nsetInterval(() => {\r\n  pubsub.publish(SOMETHING_CHANGED_TOPIC, {somethingChanged: {id: id++}})\r\n}, 2000)\r\n```"},"comment":{"url":"https://api.github.com/repos/apollographql/subscriptions-transport-ws/issues/comments/349094245","html_url":"https://github.com/apollographql/subscriptions-transport-ws/issues/307#issuecomment-349094245","issue_url":"https://api.github.com/repos/apollographql/subscriptions-transport-ws/issues/307","id":349094245,"user":{"login":"drFabio","id":2636143,"avatar_url":"https://avatars1.githubusercontent.com/u/2636143?v=4","gravatar_id":"","url":"https://api.github.com/users/drFabio","html_url":"https://github.com/drFabio","followers_url":"https://api.github.com/users/drFabio/followers","following_url":"https://api.github.com/users/drFabio/following{/other_user}","gists_url":"https://api.github.com/users/drFabio/gists{/gist_id}","starred_url":"https://api.github.com/users/drFabio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drFabio/subscriptions","organizations_url":"https://api.github.com/users/drFabio/orgs","repos_url":"https://api.github.com/users/drFabio/repos","events_url":"https://api.github.com/users/drFabio/events{/privacy}","received_events_url":"https://api.github.com/users/drFabio/received_events","type":"User","site_admin":false},"created_at":"2017-12-04T20:26:02Z","updated_at":"2017-12-04T20:26:02Z","author_association":"NONE","body":"0.9.3 seems to have solved it."}}
{"actor":{"display_login":"drFabio"}}