Skip to content

GraphQL auto-configuration should not back off when existing GraphQlSource bean #33096

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

Closed
bclozel opened this issue Nov 10, 2022 · 0 comments
Closed
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Nov 10, 2022

As discussed in spring-projects/spring-graphql#526, Spring for GraphQL did not adopt a "code first" approach (generating the GraphQL schema from Java method signatures), but rather a "schema first" approach (manually crafting a schema as the core contract of the service and controllers registering data fetchers for this schema).

While Spring for GraphQL is not designed with "code first" approaches in mind, we don't want to prevent developers from building such infrastructures in their projects. Currently, the main GraphQL auto-configuration is annotated with @ConditionalOnGraphQlSchema which checks for the presence of one of:

  • schema files on the classpath, in the location pointed by spring.graphql.schema
  • GraphQlSourceBuilderCustomizer customizer beans

If developers want full controller over the GraphQL schema, the Spring GraphQL team currently advises to create your own GraphQlSource bean. The current implementation of the condition prevents that and developers currently put an empty "schema.graphql" file to work around this problem. We should revisit this condition implementation to also consider GraphQlSource beans.

@bclozel bclozel added the type: enhancement A general enhancement label Nov 10, 2022
@bclozel bclozel added this to the 3.0.x milestone Nov 10, 2022
@bclozel bclozel self-assigned this Nov 10, 2022
@bclozel bclozel modified the milestones: 3.0.x, 3.1.x Nov 10, 2022
@bclozel bclozel removed their assignment Nov 10, 2022
@wilkinsona wilkinsona modified the milestones: 3.1.x, 3.x Apr 18, 2023
@bclozel bclozel self-assigned this Jan 19, 2025
@bclozel bclozel modified the milestones: 3.x, 3.5.0-M1 Jan 19, 2025
@bclozel bclozel changed the title ConditionalOnGraphQlSchema prevents code first approaches GraphQL auto-configuration should not back off when existing GraphQlSource bean Jan 20, 2025
arefbehboudi pushed a commit to arefbehboudi/spring-boot that referenced this issue Jan 29, 2025
Prior to this commit, the GraphQL auto-configuration that defines the
infrastructure beans for base support would only be active when:

* GraphQL schema files are detected in the configured locations
* or if GraphQlSourceBuilderCustomizer beans are present

This would allow some "code first" approaches, but not situations where
developers contribute their own `GraphQlSource`. This commit ensures
that the auto-configuration is processed even if the application only
contributes a custom `GraphQlSource` bean.

Closes spring-projectsgh-33096

Signed-off-by: arefbehboudi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants