Skip to content

Refine GraphQL server auto-configuration #30035

Closed
@bclozel

Description

@bclozel

As of spring-projects/spring-graphql#10, Spring GraphQL ships a GraphQlClient; this brings a new use case for the Spring GraphQL starter: building an application that consumes a remote GraphQL API but does not expose one.

Right now the GraphQlAutoConfiguration is only conditional on the presence of spring-graphql. With that, an application that just want to use the client will fail at startup, since we're trying to find graphql schema files on the configured classpath locations and fail if none was found. This is by design as a schema-less GraphQL API is invalid.

We should refine the GraphQlAutoConfiguration and add a custom condition that triggers the auto-configuration only if:

  1. we detect schema files in the configured locations
  2. OR we detect GraphQlSourceBuilderCustomizer as those can contribute to the schema

So far it doesn't seem we need extra auto-configuration for the client use case, as Spring Boot already contributes a WebClient.Builder and other opinions cannot be inferred from the application environment.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions