Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support current apollo subscriptions #51

Open
lorensr opened this issue Nov 17, 2017 · 0 comments
Open

Support current apollo subscriptions #51

lorensr opened this issue Nov 17, 2017 · 0 comments

Comments

@lorensr
Copy link

lorensr commented Nov 17, 2017

Sorry for the lack of PR—working in a generated server with lots of other changes! Latest version of apollo-link-ws uses graphql-ws as the protocol, which isn't supported by

"subscriptions-transport-ws": "0.2.6"

image

HTTP/1.1 400 Bad Request
Connection: close
X-WebSocket-Reject-Reason: Unsupported protocol.

Fix

package.json
-    "subscriptions-transport-ws": "0.2.6"
+    "subscriptions-transport-ws": "^0.9.1"
-    "graphql": "0.7.2",
-    "graphql-server": "^0.3.2",
-    "graphql-server-express": "^0.4.3",
-    "graphql-subscriptions": "0.2.0",
-    "graphql-tools": "^0.8.2",
+    "graphql": "^0.11.7",
+    "graphql-subscriptions": "^0.5.4",
+    "graphql-tag": "^2.5.0",
+    "graphql-tools": "^2.6.1",
+    "apollo-cache-inmemory": "^1.0.0",
+    "apollo-client": "^2.0.1",
+    "apollo-link-http": "^1.1.0",
+    "apollo-server-express": "^1.2.0",

example resolver:

  Subscription: {
    githubStars: {
      subscribe: () => pubsub.asyncIterator('githubStars')
    }
  }

server/index.js:

import { execute, subscribe } from 'graphql'
...
  SubscriptionServer.create(
    {
      schema,
      execute,
      subscribe,
      onConnect: connectionParams =>
        addModelsToContext({ db, githubAPI, pubsub })
    },
    {
      server: websocketServer
    }
  )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant