How would I handle query/mutation authentication?
pqt opened this issue · comments
Hey!
First of all, I want to thank you @pgutkowski for making this, it's been a great help in working with GraphQL and Kotlin, taking away a lot of the headaches I was running into before finding this.
Overall my implementation went fairly smooth. I am able to resolve queries and mutations accurately and even have registration for an app completely done.
My problem now though, is trying to blend Ktor's JWT and specific queries/mutations together.
I can protect the graphql route entirely , but that doesn't work well for th registration and login process.
I know there's a context
variable on schema.execute
but I'm not certain if this is how I should be passing authentication data down stream.
Hey @pqt!
I'm happy that you find KGraphQL useful! You are right - context is meant to be container for authorization data. Unfortunately, it has limitations: you can only use it in root level queries and mutations, see #42. I hope I will find time soon to extend context variable access to properties.
I'm sorry it took me so long to respond.
Thanks a lot for making this project! Really cool and useful!
And I also want to vote for this feature: it would be really useful if it would be possible access context from resolver!!!
I ended up actually having to put the prototype on hold (for now) because of this limitation, but I still think you've got a great project here!