Describe the bug
I'm trying to implement the cart with GrahpQL but after i few days I get this error: Uncaught (in promise) Error: GraphQL error: Expired token. Unfortunately this error is keeping me from going into production. I can't load the cart, and I can't add to cart. The woocommerce-session is present client side and if I clear it everything works as expected. I'm fetching stock and prices with Apollo and that's working.
Here is my Apollo client.js. I'm using GatsbyJS.
Any help appreciated.
To Reproduce
Expected behavior
Should recognise session token and load cart.
Screenshots

I reckon I have to implement a token refresh mechanism in my Apollo client. But I'm unsure of what token the error is referring to? I'm not using auth for my site, does the add to cart mutation send a JWT token? As i understand the woocommerce-session token should stay the same since I want to persist the cart between sessions. Can anyone point me in the right direction? 馃檹
Hi @zamson, have you fixed it? Having the same problem, but as far as I know, as of now, only the AddToCart mutation is capable of generating a new token.
@dawgor The token is a JWT token that got an expiry (~48h). Our solution was to remove the token if it has expired and set a new one in the apollo-client. Maybe not the best solution but one that is working.
Sharing the code here. The check is done in the middleware.
@zamson Oh, i see. Thank you!
Most helpful comment
@dawgor The token is a JWT token that got an expiry (~48h). Our solution was to remove the token if it has expired and set a new one in the apollo-client. Maybe not the best solution but one that is working.
Sharing the code here. The check is done in the middleware.