skip to Main Content

I am trying to implement authentication in a custom resolver function but to achieve that, I must be able to set a cookie on the response.

I found the following docs on what data is available, unfortunately, I see no way to access the response object nor the response headers. How would this be achievable?

2

Answers


  1. If you want to set something in the response of the graphQL you can use EndRequestEvent.

    Login or Signup to reply.
  2. I recommend you to keep the HTTP layer separate from the GraphQL layer. That means:

    • don’t deal with cookies in resolvers
    • don’t expect certain resolvers in HTTP middleware

    In my experience, authentication work best when handled exclusively on the HTTP layer – use standard Laravel mechanisms such as guards, described in https://laravel.com/docs/authentication and tie it into your Lighthouse server through middleware such as NuwaveLighthouseHttpMiddlewareAttemptAuthentication.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search