Open moltar opened 6 years ago
Hey,
I'll need to dig into the documentation of Subscription Query (and Live Query that should arrive this year).
If I can use the WebSocket package of Adonis that would be 👌
I am not.clear on exactly how Adonis WebSocket package works, but it seems to be only solving the cluster problem. Meaning that if multiple forks running on the same machine - they can communicate with each other. But AFAIK it still doesn't solve the problem of multiple servers. I think Redis has already solved this problem when it comes to WS and GQL communication. So it may make sense to just use Apollo's built in mechanisms for that.
Hey,
I didn't have time to look into it.
I've tried to research this issue, and there some troubles, please look an issue: https://github.com/adonisjs/adonis-websocket/issues/56
how I connected subscriptions into adonisjs: in start/hooks.js:
hooks.after.httpServer(() => {
const Server = use('Server')
const { execute, subscribe } = require('graphql')
const { SubscriptionServer } = require('subscriptions-transport-ws')
const GraphQLServer = use('Adonis/Addons/GraphQLServer')
let server = Server.getInstance()
new SubscriptionServer({
onConnect: () => {
console.log('onConnect')
},
onSubscribe: () => {
console.log('Subscribing')
},
onUnsubscribe: () => {
console.log('Unsubscribing')
},
onDisconnect: () => {
console.log('Disconnecting')
},
execute,
subscribe,
schema: GraphQLServer.$schema
},
{
server,
path: '/subscriptions',
})
})
Maybe it will help to make subscriptions in adonis-graphql
Does this implementation of hooks work perfectly? How do I make calls on my resolvers?
Even though I do not use this library, I use only the repositories "adonis-apollo-server": "^ 1.0.2", "graphql": "^ 14.0.2", "graphql-tools": "^ 4.0.3"
@yariksav please
@yariksav I also please for more description :) Currently I have same problem with using Graphql Subscriptions in Adonis
I am sure you have been thinking about this too. Just want to open an issue to track this and share ideas.
I noticed there is active development in adonis-websocket repo, which means it might be released soon.
On the other hand, writing custom transport for GraphQL would be quite an undertaking. I looked at the code of
subscriptions-transport-ws
and there are a lot of moving parts. Maintaining a separate package just for Adonis might be a huge overhead.Not sure if there is a way to marry the two.
Any thoughts on this? Would perhaps the standard
subscriptions-transport-ws
way with Redis backing would suffice for most use cases? Maybe the PubSub backend could be just configurable via a provider.