Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test response headers? #11

Open
ziimakc opened this issue Nov 14, 2022 · 1 comment
Open

Test response headers? #11

ziimakc opened this issue Nov 14, 2022 · 1 comment

Comments

@ziimakc
Copy link
Contributor

ziimakc commented Nov 14, 2022

Is there a way to test response headers?

@kylerush
Copy link

kylerush commented Dec 16, 2022

Currently it doesn't look like it is possible to test the response headers. The response heads could be exposed to this function since under the hood it uses fastify.inject which does give you the response headers.

My use case for testing the response headers is the following. My app has a sign-in GraphQL mutation, that uses @fastify/session to create a signed session cookie. The GraphQL mutation does not respond with the value of the cookie. This is fine for testing authentication. The logout GraphQL mutation calls session.destroy() and when I send the request to logout, I would need to send the sessionId cookie with the signed cookie value that I do not have. To fix this, we could modify the mercurius-test-client to also return the response headers (where I could get the set-cookie header value and use the cookie for the subsequent logout mutation) in addition to the response body. This, however, would be a breaking change.

I do like the simplicity of this module. @PabloSzx, in this situation, do you think we should modify mercurius-test-client to return the response headers in addition to the response body for this test case or should I just use fastify.inject? Either solution seems fine to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants