hello :wave: is there a way to update already conf...
# ktor
d
hello 👋 is there a way to update already configured routes? i.e. got a plugin that configures routes but some folks would like to add some processing around it (e.g. authentication)
a
How exactly the plugin configures routes?
a
With the above implementation, you can’t. You can extract your routes into a separate method with the
Route
type receiver, to give the users ability to call it in any place in the routing. Inside that method, you can acquire an instance of your
GraphQL
plugin to configure the routes using the
GraphQLConfiguration
.
d
by any chance do you know of some example code that I could look up? somewhat confused how would I get an instance of the plugin in other places guessing you are suggesting a pattern similar to what authenticate plugin does, i.e.
Copy code
install(Authentication) {
  // configuration
}
install(Routing) {
  authenticate(<config>) {
    // route config
}
a
Yes, exactly.
d
how would I get access to my plugin from route though?
sticking stuff up to
ApplicationCall#attributes
? or is there some better way
a
You can get an instance of the plugin by
call.application.plugin(<PluginClass>)
d
👍
is there a way to ensure that routes get created by default? i.e. if someone does not install routing I'd like to autoconfigure the defaults
guess could expose it as
Copy code
install(GraphQL) {
  // config
}
install(Routing) {
  graphQLRoute() // <-- requires explicit user config
  graphiQLRoute()
}
a
In this way you can’t ensure that.
d
but if I don't do it this way then folks cannot configure auth stuff 😞 so guess kind of have to
thanks
a
Generally, this can be solved by a documentation.
d
another follow up question
I was installing
ContentNegotiation
globally by
Copy code
pipeline.install(ContentNegotiation) {
  jackson(streamRequestBody = config.server.streamingResponse) {
    apply(config.server.jacksonConfiguration)
  }
}
but this was breaking users who wanted to use different content negotiation on some other routes
someone opened up the PR that moved it to the routing block -> https://github.com/ExpediaGroup/graphql-kotlin/pull/1684
a
Yes, you can install the
ContentNegotiation
plugin into specific routes
d
sounds like the fix was not correct -> it should be applied per route
👍 i'll fix it up with the refactor
thanks