-
Notifications
You must be signed in to change notification settings - Fork 317
Code-first support of annotated controllers #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello @itzg As explained in this comment, we expect developer to contribute a As you've pointed out,
As you've probably seen, Spring for GraphQL did not choose the code first approach and we don't think we should revisit this choice. It would be interesting indeed to see how a solution similar to Springfox would work in this case. I'm not sure our annotation model would be enough to generate a complete and consistent schema. What have you tried so far? Have you found limitations or extension points that we could provide to make this use case easier? |
Thank you for your prompt response @bclozel !
Agreed, it's not complete since it doesn't (yet) extract the property level structure of the return type, arguments and similar introspection.
That's reasonable. Mainly I wanted to find out if this was a "forever choice" or just a not-in-the-next major release or two.
Agreed. More annotations would be needed to convey the deeper/precise intent. Basically I was hoping/expecting the concepts in graphql-spring-annotations were to be folded into spring-graphql. That project seems to be quite out of date, so it itself didn't not seem viable for a production grade requirement.
Admittedly not much and also admittedly it was the graphql-java setup of the My only specific suggestions at this point are
Having said that, perhaps my expectation of using |
Good point. We discussed that with @rstoyanchev recently. We noticed that the auto-configuration is quite opinionated and doesn't necessarily support the code-first approaches as it could. As a side note, Spring for GraphQL is very much tailored for schema-first as we think the GraphQL schema must be carefully designed and communicates a lot to the consumers. We don't want to prevent code-first approaches with Spring for GraphQL, but we have limited resources to dedicate to this particular theme, given all the other features requested by the community. |
Thank you for the confirmation and clarification. |
Thanks @itzg for the follow up replies, I've created spring-projects/spring-boot#33096 to improve the |
With modern Spring, especially with Spring Boot, development of external application interfaces is very commonly declared via Java/annotation based configuration, such as Spring MVC and annotation-based WebFlux. Robust OpenAPI schema generation can be performed with Springfox.
As such, the presence of annotated controller support gave the initial impression that a familiar, Spring-like code-first approach was supported. As of https://github.com/spring-projects/spring-graphql/releases/tag/v1.0.2 that is not the case -- Spring Boot auto-configuration of GraphQL is completely disabled if GraphQL schema files are not present.
I see there has been various discussions and offered application solutions for code-first:
The solutions appear to be fairly complex and indirectly derive the schema from the runtime wiring. The mechanics of constructing the runtime wiring by the AnnotatedControllerConfigurer seem more appealing since it is already traversing the surface of type-safe declarations of GraphQL integration points.
FWIW, I encountered this "limitation" during an exercise to introduce GraphQL into our product and use the exercise as an opportunity to steer the platform away from Quarkus to Spring. It turns out that Quarkus has first-class (and only) support for code-first declaration of GraphQL, which is built upon Smallrye GraphQL.
The text was updated successfully, but these errors were encountered: