You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
Closesspring-projectsgh-33096
Signed-off-by: arefbehboudi <[email protected]>
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:spring.graphql.schema
GraphQlSourceBuilderCustomizer
customizer beansIf 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 considerGraphQlSource
beans.The text was updated successfully, but these errors were encountered: