Using KeystoneJS 6 in a decoupled setup, the mutation loginUser returns a session token, yet external queries yield an undefined session. Code sample:
mutation loginUser($userEmail: String!, $userPass: String!) {
loginUser(email: $userEmail, password: $userPass) {
sessionKey
}
}
How can this be resolved?
In my experience, the undefined session issue typically arises from misconfigured session handling in a decoupled environment. It is essential to ensure that the authentication mechanism properly sets the session cookie or header parameter that the frontend relies on. This might involve adjusting the cookie domain settings or explicitly passing session tokens in subsequent queries. I resolved a similar issue by verifying that the Keystone session configuration correctly linked the persistence of the token to the subsequent GraphQL requests. Reviewing session middleware and token propagation details in KeystoneJS documentation is also advisable.
hey, i had a similiar issue. i fixed mine by rechecking cookie domain setups and making sure the token header sent propperly. might help if you verify your config too. cheers!