I have an existing application running in a non-Spring application server. I'd like to integrate a GraphQL API into that application using spring-graphql. How would I go about that? My intention was to get a reference to the GraphQlSource to execute queries sent to an HTTP endpoint implemented in this server. In learning about spring-graphql, I went through the tutorial by generating a Spring Boot application using Spring GraphQL and MVC. I also created a component that obtained a reference to the GraphQlSource via auto-wiring and was able to execute GraphQL queries on the server side.
Now, I want to take what I've prototyped and integrate that into my existing application server without requiring a full-fledged application. I think what this boils down to is creating a GraphQLSource that is configured identically to the one created by GraphQlAutoConfiguration without actually having to call SpringApplication.run() on a SpringBootApplication.
I realize that I could just create a GraphQLSource directly, but I like some of the additional configuration magic that GraphQlAutoConfiguration applies.
This documentation enhancement was requested by the community. In general, you should consider 3 essential beans for your infrastructure:
AnnotatedControllerConfigurer
that supports @Controller
GraphQL handlersExecutionGraphQlService
that is responsible for processing GraphQL requests in a transport-agnostic fashionRouterFunction
that plug web transport handlers (HTTP, SSE, WebSocket...) into the Spring MVC functional frameworkA minimal Spring for GraphQL "standalone" setup is now described in a dedicated section of the reference documentation.