Skip to content

Using different schema for authorized/unauthorized requests #1857

Answered by JajaComp
JajaComp asked this question in General
Discussion options

You must be logged in to vote

In the end I managed to solve the problem:

  1. Create custom route for post request:
private fun Route.graphQLPostRoute(): Route {
    val ktorServer = get<KtorServer>()
    return route("/graphql", HttpMethod.Post) {
        handle {
            ktorServer.handle(this.call)
        }
        install(ContentNegotiation) {
            jackson(streamRequestBody = true) {}
        }
    }
}
  1. Create instance for Guest graphql server:
internal class GuestGraphql(
    private val contextFactory: GuestGraphQLContextFactory,
    private val dataLoaderRegistryFactory: KotlinDataLoaderRegistryFactory,
) {
    private val graphQl: GraphQL
    val server: KtorGraphQLServer
        get() = graphQl.ser…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dariuszkuc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #1850 on September 21, 2023 18:25.