-
Notifications
You must be signed in to change notification settings - Fork 5
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
Can't get subscriptions to work reliably #12
Comments
@Twisterking pls create reproduction repo. |
So I did some more research, but in a very basic setup I copied the following stuff over 100% identically:
import { typeDefs, resolvers } from '/api/schema';
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
createApolloServer({
schema
}); Both versions (the very basic setup (https://github.com/Twisterking/meteor-graphql-test) and the real app) are connected to the BOTH versions use the same setup for subscribing to my openorderbody/cart: openorderbody: {
resolve: ({ event, doc }, args, context, ast) => {
console.log('openorderbody sub resolve:', { event, doc, args });
doc.__typename = 'OpenOrderElement';
if(event == 'added' || event == 'changed') {
Object.assign(doc, {
item: Items.findOne(doc.itemId)
});
}
return { event, doc };
},
subscribe(_, args, context) {
const { openOrderId } = args;
const openOrderHead = OpenOrdersHead.findOne({ _id: openOrderId });
if(!openOrderHead) {
console.error(`openOrderHead not found for _id ${openOrderId}`);
return;
}
console.log('SUB openOrderHead', openOrderHead);
const observable = OpenOrdersBody.find({ list_id: openOrderId });
return asyncIterator(observable, {
sendInitialAdds: true
});
}
} I my minimal version, the Any ideas how this is possible? Since all of this is server-only, it really should be a server-only problem correct? |
Hi guys,
After hours of trying pretty much everything I could come up with, I gave up for now - I can't get GraphQL subscriptions to work reliably. Randomly it kinda works, most of the time it does not.
Following setup:
What do I want to achieve (for now): Just load some items from a collection with a limit and skip (pagination). If something changes in the currently loaded (e.g. 20) items, the subscription should update the items - obviously. 😄
some code:
SERVER:
Any my Client:
I really really hope someone can help. I would be glad to even pay for maybe 30min - 1h of your time. I am pretty desperate right now, as I think my setup is pretty basic and it is not working at all.
Thanks a bunch for any help in advance! Cheers, Patrick
The text was updated successfully, but these errors were encountered: