router
router copied to clipboard
Provide the parsed operation AST through the Rust plugin context
Is your feature request related to a problem? Please describe.
I want to parse all my operations with apollo-rs using the ApolloCompiler to run custom diagnostics like how many times a field was referenced or what directives were used. The Router is already parsing the operations today to do it's logic but when it shares the data with the plugins, I only have access to the raw schema SDL and raw operation string. It would save resource if we could have access to the same compiler object as Router.
Describe the solution you'd like
Exactly how this example parses the supergraph and current query AST using ApolloCompiler, I would like the resulting ctx to be available in the request context so I don't have to parse again.
If Router did this parsing once for all the standard work then saved the value in the Context, we could reference the ApolloCompiler type to run custom AST queries.
Describe alternatives you've considered
I can add this custom plugin and do this myself today. ApolloCompiler is really fast so the overhead should be minimal but we are still doing some duplicate work that could be reduced
This also is only relevant for Rust plugins and not coprocessor. You could do this same thing in the coprocessor though and in that case having access to the schema hash could also you help figure out if you had to re-parse the schema again
Additional context
This was previously asked for here: https://github.com/apollographql/router/issues/1725