Has anyone here used Meteor methods inside of their Apollo GraphQL resolvers? I have a situation where I have a meteor server also running an Apollo server (per the Apollo docs), and I can access the logged in user via context.userId, or by calling meteor methods on the client, but when I try to call a meteor method inside the Apollo resolver, this.userId returns as null.
Directly updating the Mongo.Collection from my resolvers appear to work fine, but I have some denormalizing hooks attached to one of my collections that call other Meteor methods, and I would prefer to keep those functioning properly, but they require this.userId. This seems odd that I am seeing partial functionality of Meteor’s server side environment, but don’t have access to all of it. Any help would be greatly appreciated. Thanks
Using DDP and DDPCommon like the suggestion in your second link worked, though I haven’t tested it completely yet. I had a hard time following your discussion regarding context, but it made me think using these methods might lead to the possibility of userId’s being crossed/assigned to the wrong user. Is that a possibility?
I actually tried that suggestion right before posting here, and Meteor throws an error saying you can’t set userId from a server call. I assume it’s a security feature.