Skip to content

Code-first support of annotated controllers #526

@itzg

Description

@itzg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions