apollographql / router

A configurable, high-performance routing runtime for Apollo Federation 🚀
https://www.apollographql.com/docs/router/
Other
810 stars 273 forks source link

Toggle introspection on a per request basis (runtime) #3493

Open tinnou opened 1 year ago

tinnou commented 1 year ago

Is your feature request related to a problem? Please describe. In the router, it is possible to disable/enable introspection resolution by using the config property supergraph.introspection.enabled:true. In our case, we would like to control introspection on a per request basis. For example we would like to only allow introspection for internal requests / users. If we detect a request is external, we would like to disable introspection for the request.

Describe the solution you'd like A few approaches come to mind:

Describe alternatives you've considered As a workaround, we implemented a supergraph_service plugin that performs the internal/external check per request. The problem is it also needs to parse the query again to find out whether it contains introspection fields and perform the deny/allow that the router already performs further down the chain. This is suboptimal performance wise and also logic wise since introspection detection logic is duplicated in user and router code.

BrynCooke commented 1 year ago

Typically we don't recommend enabling introspection outside of dev. If you're a managed federation user then you can rover to fetch a graph schema even when introspection is disabled: https://www.apollographql.com/docs/rover/commands/graphs#graph-fetch

Would using rover be an option for you?

BrynCooke commented 12 months ago

We plan to stabilize apollo-rs first quarter of next year. When this happens it will be easy for users to create a plugin that does the above.