I have an authentification mutation that currently...
# graphql-kotlin
j
I have an authentification mutation that currently returns a JWT token in the response body. I don't really like that because the browser has nowhere to securely store the token. I would like instead to set the
Cookie
header using my framework of choice (ktor). I understand how I can read Cookies and header before the GraphQL request with.
GraphQLContextFactory
but is it possible to set
Cookie
header after my GraphQL mutation succeeds? I would have expected this in
environment: DataFetchingEnvironmen
but no luck.
j
We've done this in our dropwizard based server by having the mutation put a
NewCookie
instance into the
graphQLContext
map and setting it on the response. Something similar should be doable in a ktor based server. https://github.com/trib3/leakycauldron/blob/main/graphql/src/main/kotlin/com/trib3/graphql/resources/GraphQLResource.kt#L154-L158
👍 1