You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In the context of using Ktor, there is a problem with the current implementation of Route.graphQLPostRoute() in graphql-kotlin. When this method is used, it internally installs the ContentNegotiation plugin. This prevents setting ContentNegotiation globally and results in an exception, as follows:
io.ktor.server.application.DuplicatePluginException: Installing RouteScopedPlugin to application and route is not supported. Consider moving application level install to routing root.
For instance, when using the StatusPages plugin to set up a global exception handler that returns JSON responses, we need to install ContentNegotiation globally. Without this, we must manually serialize JSON and set the Content-Type, which is cumbersome.
Describe the solution you'd like
I suggest modifying the implementation to check if ContentNegotiation is already installed at the application level using route.application.pluginOrNull. If it is, the method should skip the internal setup of ContentNegotiation.
Describe alternatives you've considered
An alternative solution would be to provide an argument that allows the user to skip the internal installation of ContentNegotiation. This would give developers control over whether to use the global or route-specific configuration.
Additional context
If there are any workarounds or better approaches, please let me know. Thank you!
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
In the context of using Ktor, there is a problem with the current implementation of Route.graphQLPostRoute() in graphql-kotlin. When this method is used, it internally installs the ContentNegotiation plugin. This prevents setting ContentNegotiation globally and results in an exception, as follows:
For instance, when using the StatusPages plugin to set up a global exception handler that returns JSON responses, we need to install ContentNegotiation globally. Without this, we must manually serialize JSON and set the Content-Type, which is cumbersome.
Describe the solution you'd like
I suggest modifying the implementation to check if ContentNegotiation is already installed at the application level using route.application.pluginOrNull. If it is, the method should skip the internal setup of ContentNegotiation.
Describe alternatives you've considered
An alternative solution would be to provide an argument that allows the user to skip the internal installation of ContentNegotiation. This would give developers control over whether to use the global or route-specific configuration.
Additional context
If there are any workarounds or better approaches, please let me know. Thank you!
The text was updated successfully, but these errors were encountered: