Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option to Skip Internal ContentNegotiation Installation in graphQLPostRoute() #2025

Open
agatan opened this issue Aug 6, 2024 · 1 comment
Labels
type: enhancement New feature or request

Comments

@agatan
Copy link

agatan commented Aug 6, 2024

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!

@agatan agatan added the type: enhancement New feature or request label Aug 6, 2024
@Ayush-Kotlin-Dev
Copy link

Ayush-Kotlin-Dev commented Sep 21, 2024

yeah , got the same issue , i can't able to use contentnegotiation globally because of graphql internal ContentNegotiation plugin.

DO anyone have solution for this issue

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
Development

No branches or pull requests

2 participants