Skip to content

Conversation

@sjohnr
Copy link
Contributor

@sjohnr sjohnr commented Jul 7, 2025

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Changes in this PR

  • Invoke checkTypeResolverExists() after @DgsRuntimeWiring to allow strict mode to be enabled with type resolvers registered via @DgsRuntimeWiring

Prior to this PR, enabling strict mode (dgs.graphql.strict-mode.enabled=true) could cause failures if applications use the RuntimeWiring.Builder to register type resolvers in methods annotated with @DgsRuntimeWiring. This PR moves the logic in DgsSchemaProvider to only automatically register type resolvers for interface and union types after callbacks to user code (@DgsScalar, @DgsDirective, @DgsData, @DgsTypeResolver, @DgsCodeRegistry, but mainly @DgsRuntimeWiring).

This allows applications to register custom type resolvers for interface and union types with strict mode enabled, as in the following example:

@DgsComponent
public class MyRuntimeWiring {
    @DgsRuntimeWiring
    public RuntimeWiring.Builder runtimeWiring(RuntimeWiring.Builder builder) {
        builder.type("MyInterfaceType", type -> type.typeResolver(new MyInterfaceTypeResolver()));
        builder.type("MyUnionType", type -> type.typeResolver(new MyUnionTypeResolver()));
        return builder;
    }
}

Closes gh-2180

@sjohnr sjohnr merged commit 59bada3 into master Jul 9, 2025
2 checks passed
@sjohnr sjohnr deleted the gh-2180 branch July 9, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Invoke DgsSchemaProvider.checkTypeResolverExists() after all the callbacks to user code have been performed

3 participants