I can’t understand why context.userId
is empty after Accounts.createUser()
. In my apollo-meteor app on client:
const user = {
email: form.values().email,
password: form.values().password,
};
Accounts.createUser(user, (e, r) =>{
if (e) {
form.invalidate(e.reason)
} else {
browserHistory.push('/')
}
});
After this, I have an apollo query on my index route /
with a resolver:
user(root, {id}, context) {
console.log(id, context)
if (context.userId === id) {
return context.user;
}
},
And it seems that after redirecting with browserHistory.push('/')
context is empty, but after reloading the page it sends me back a proper userId. I even tried to set up a timeout before browserHistory.push('/')
, but of course it didn’t help. Any suggestions hot to fix it? I guess I have to ask the graphql server to reload context after successful Accounts.createUser
and I tried to google it, but completely unsuccessful.