Closed alexknipfer closed 6 years ago
Hey I just randomly came across your question, but I remember getting a similar error because subscriptions (unlike query/mutation) don't take a function. They just have an object which has a subscription, which in turn takes a function. I altered your code (just really the const discAdded
line and an extra )
at the end), I hope it works.
const socket = require('../../lib/socket')
const { withFilter } = require('graphql-subscriptions')
const discAdded = ({
subscribe: withFilter(
() => socket.asyncIterator('DISC_ADDED'),
(payload, variables) => {
return payload.createdBy === variables.createdBy
}
)
})
Thanks for the reply, good to know it doesn't take a function. Unfortunately, this is still causing the same error of Subscription must return Async Iterable. Received: undefined
in the payload.
@alexknipfer
I just had a look at your repo and I think you forgot to add the Subscriptions in your resolvers: https://github.com/alexknipfer/DiscShareServer/blob/subscriptions/api/resolvers/index.js
@ravenscar Thank you so much man! Didn't even catch that, after making that change and returning an object, that did the trick!
I can't seem to solve this particular issue creating a subscription. In the payload, I'm receiving the following error:
Subscription must return Async Iterable. Received: undefined
Subscription looks as follows:
Full repo here: https://github.com/alexknipfer/DiscShareServer/tree/subscriptions
Any help greatly appreciated!