reactql / example-auth

User auth, session & JWT example for ReactQL
48 stars 17 forks source link

Pass cookies to external graphql on ssr #3

Closed kyzia551 closed 7 years ago

kyzia551 commented 7 years ago

Hello, Lee! Thank you vey mutch for your great example!

My question a little bit outside. What to do if i use external graphQL endpoint? How to send cookie with JWT in case of server rendering? I recieve it in koa, but can't understand how to pass cookie to graphQL request.

leebenson commented 7 years ago

If your GraphQL server/endpoint sends cookies, you'd need to edit kit/entry/server.js and change how the per-request Apollo client is instantiated, so that it could parse the cookie response, and then send that as the JWT token. Everything after that point should be the same.