Inspired by this discussion I let the builder extend the GraphQLSchema.Builder class so it exposes regular builder methods.
I then exposed the builder (as a GraphQLSchema.Builder, not as a GraphQLSchemaBuilder) in the GraphQLExecutor to allow adding mutations runtime.
To keep the bean properties so the executor can be retained as autowired, I allowed the schema manipulations to happen post-construction. To address lestranges comment this could pave the way for dependency injection (1) and hides the specific implementation of the GraphQLSchemaBuilder, so it can be renamed/refactored to what it actually is: a wrapper for the builder that automatically constructs a (initial) schema from JPA entities.
As a practical example, changing the schema with this PR could look something like this:
Inspired by this discussion I let the builder extend the GraphQLSchema.Builder class so it exposes regular builder methods.
I then exposed the builder (as a GraphQLSchema.Builder, not as a GraphQLSchemaBuilder) in the GraphQLExecutor to allow adding mutations runtime.
To keep the bean properties so the executor can be retained as autowired, I allowed the schema manipulations to happen post-construction. To address lestranges comment this could pave the way for dependency injection (1) and hides the specific implementation of the GraphQLSchemaBuilder, so it can be renamed/refactored to what it actually is: a wrapper for the builder that automatically constructs a (initial) schema from JPA entities.
As a practical example, changing the schema with this PR could look something like this: