-
Notifications
You must be signed in to change notification settings - Fork 535
Subscriptions support #390
Comments
+1 |
2 similar comments
+1 |
+1 |
subscriptions-transport-ws should create a websocket server. And I figured it out like below by adding subscription operation support in express-graphql's graphiql explorer.
Let me know if this solves the issue and I can create a PR. |
@junminstorage this didn't work out for me. I had to plug the module graphql-playground-middleware-express to make it work, but I'm still investing what's the issue tho, given that I'm not sure if the problem is with GraphiQL not triggering the connection. |
@calvernaz thanks for bringing this up. conjunction with above I will need make a PR to expresss-graphql to make it work. |
PR: #436 |
Sure @junminstorage, is the fix pinned to any specific version? |
I merged the current master to my PR branch. Actually it should work for last release as well which I tested. But if you can help me try it out with latest release and confirm, then we have good confidence to ask @IvanGoncharov to approve it. |
The last version still doesn't work, and it makes sense for me given that commit is not merged yet. Maybe it worked for you because was cached or you missed to delete your local copy? I tried to point my dependency to your repository but without success, not sure why npm refuses to pull the code from there. |
Right, the PR is not merged yet and not in any releases. I was meaning the changes in the PR should work for any release greater than v0.6.12 and master too. For your local test, you need to remove the existing express-graphql in the node_modules/ folder under the nodejs project you are working on, then git clone https://github.com/junminstorage/express-graphql/ , and checkout branch named 'subscription-graphiql-support', then do npm link install this specific project, see doc here: https://docs.npmjs.com/cli/link Let me know if you still have any problems after doing this. I am planning to build a sample project here: https://github.com/junminstorage/graphql-sample, so you may be able to check it out and run it to see how it works. But it will take me some time to do it. |
Yep, the source code is typescript. And that is awesome! Thank you! @IvanGoncharov can you comment on the PR #436 and so we can move forward on this? |
@junminstorage I left a comment in #436 (comment). |
Hi! this PR was commited? I'm trying to do the same thing, but, doesn't worked here... |
Can you check if this works for you? https://github.com/calvernaz/express-graphql |
just commented here to show my willing to work on this PR if anything we need for it to merge |
hello, @calvernaz . |
@Lcmkey, besides you need the code changes like in PR #436 to express-graphql, rebuild the dist/ folder inside, Or point (npm link) your local express-graphql to https://github.com/calvernaz/express-graphql, do you also have the code snippet like below in your server side? |
@junminstorage |
Is there a complete example somewhere ? I have been trying to make subscriptions work with express-graphql and subscriptions-transport-ws with no success. See below the src, if you see any issue let me know. The subscribe function is never triggered, the client can be run in command line (no browser). My server:
Client:
package.json:
|
same problem. anyone here could help us. |
@calvinlarano97, @martinlevesque There is currently no support for subscriptions in this package. I integrated this PR into my own package for use in my course on GraphQL, but it should be noted that it was for demonstration purposes only. https://github.com/graphql-in-motion/express-graphql I have been following this issue for at this point a few years, and I wouldn't get your hopes up that the maintainers will do anything about it anytime soon. The best option is likely to find another package to build your server. |
Is this project even still maintained? |
currently apollo graphql is the most popular platform for anyone who wants to adopt graphql in production, lacking support from the facebook for this project, making my PR #436 sitting there for long time. |
@IvanGoncharov got your point. Now winter is coming along with holidays, and now I am thinking about raising my sleeves to write my own and replace the subscription client. |
Why I bump this feature request? Honestly, I need dynamically reload schema with a subscription feature, express-graphql is easy enough for doing dynamic schema loader. |
@martijnwalraven So it seems that the current consensus from GraphQL Foundation is to try to provide some kind of hook/callback that allows you to use different transports for subscriptions including WS transport from Apollo. |
@IvanGoncharov That's something I can look into. |
@IvanGoncharov can you elaborate on this? as all of the sample code people provided above, for the express backend to support the subscription, it is up to application developer to hook up any SubscriptionServer into express and work with this express-graphql middleware. the PR is mainly to pass ws endpoint to front-end, https://github.com/graphql/express-graphql/pull/436/files#diff-1fdf421c05c1140f6d71444ea2b27638R207, the moot point or the only place third part library introduced to demonstrate the subscription capability on the UI is when it is rendered during the development phrase ONLY |
If I understand correctly (I might be wrong - noob here) the issue previously noted by @IvanGoncharov is with the package subscriptions-transport-ws being added in src/renderGraphiQL.js, not the change in src/index.js (?). Perhaps we could add the src/index.js change first to allow people to actually make it work - without subscription support in graphiql and with proper warning ? |
nope, see #390 (comment) for example. and please check out the PR linked to this issue. |
looks like this thread is dead .. its April 2020, and looks like its still stagnant for some reason though the change look pretty small.. anyone ? |
Yeah it's kind of disappointing. I would suggest adding a clear comment in the readme stating that there is no support for subscriptions, and no plan to add its support, and close this ticket. |
The community (including me) desperately needs |
hey folks! i happen to be a maintainer. happy to see what i can do. ivan has been busy with sadly this repo has been neglected far more than it should be. if anyone is interested in becoming a maintainer of this repo that would be fantastic. it is widely used still by some very large companies for now, is it ok if i close this issue and update the docs to note that this does not support subscriptions currently in the readme, and offer some links to alternatives that do? |
also if someone wants to open a pull request for this feature, i would be happy to review it! ill try to keep a closer eye out in my github notifications |
If anyone is still looking for a solution to use subscriptions in express-graphql, I have found a simple way to do this. Have a look at this |
Hey @abhijeetsingh-22 thx will look into it. Would you mind to make a repo/gist with your sample app? Edit: nevermind just saw the repo is here https://github.com/abhijeetsingh-22/Realtime-Chat-App |
Its a pleasure If I could help |
@abhijeetsingh-22 looked at your example. It works, however you basically have, if I understand correctly, two schemas, one with express-graphql and one on another http server with subscriptionserver, and the types basically need to be duplicated in both schemas. Is there a way to share types between two schemas (made an issue here abhijeetsingh-22/Realtime-Chat-App#1 ), where one use "ObjectType" and another use graphql-tags? If not it's not so much maintainable from my opinion, and not so clean, as typically you subscribe to the same types you query/mutate. |
@martinlevesque sure I will look into this issue. Currently I am little busy. I will update in 2-3 days |
works well with these 2 changes abhijeetsingh-22/Realtime-Chat-App#2 and abhijeetsingh-22/Realtime-Chat-App#1 Will have to check if it works with graphiql (I guess not?). Edit: The documentation of subscription works in graphiql also with this example. However it does not work to make it work live with streaming messages in graphiql. To me that's fine - might not be depending on your use case thus. |
The PR for this is created #687. It contains a link to tutorial project showing how it is done for subscription and web socket integration. |
graphql-ws is another good library to provide GraphQL subscription (by far, the simplest and lightest one I found). |
Whats the status on this? Would love to be able to use subscriptions for a messaging feature I have. |
oops forgot to close this ticket! juggling so many efforts in my free time 🥵 . it's very important to note that we have started with updating the docs to show how to add subscriptions support using also in @#687 we updated graphiql to work with subscriptions, but just with we will follow up with a PR and documentation on how to add And for now, I will close this ticket since we have documented this! If anyone wants to see additional features added to improve the subscriptions documentation or have any other issues, feel free to open a new one! Happy subscribing graphql-ers! |
Yeah more documentation would be great! its not super clear on how the setup works. |
- Publish a event when a new event is added ( mutation is triggered ) - Clients can connect to /subscriptions using websocket connection - migrated to apollo-server-express due to lack of subscription support in express-graphql graphql/express-graphql#390 - Update dependencies
Support GraphQL subscriptions or is there a way to use apollographql/graphql-subscriptions and apollographql/subscriptions-transport-ws with express-graphql?
The text was updated successfully, but these errors were encountered: