Open rq-trichins opened 1 week ago
You could use a BeanPostProcessor
to decorate the GraphQlSource
bean.
That said, the original idea with GraphQlSource
was to be a point of flexibility, so we could provide a more first-class way to choose the implementation by decorating the simple FixedGraphQlSource
through a method like this on GraphQlSource.Builder
:
Builder extendGraphQlSource(Function<GraphQlSource, GraphQlSource> processor);
I would like to create a custom GraphQlSource so that I can change out the GraphQlSchema based on user privileges (show one schema for admins and another schema for non-admins). Right now, the GraphQlSource created in GraphQlAutoConfiguration is always a FixedGraphQlSource. I can override the bean, but I have to copy all the code in GraphQlAutoConfiguration if I want the same functionality that already exists.
It would be nice if there was a way to have GraphQlAutoConfiguration create a non FixedGraphQlSource. One possible idea is to not have it call GraphQlSource.schemaResourceBuilder() but instead have that be a bean that can then be overridden. Or add a customizer that can take the generated FixedGraphQlSource and generate a custom GraphQlSource based on it.