dgs-framework icon indicating copy to clipboard operation
dgs-framework copied to clipboard

feature: Global Type Resolver

Open esfomeado opened this issue 1 year ago • 2 comments

Please read our contributor guide before creating an issue. Also consider discussing your idea on the discussion forum first.

Describe the Feature Request

As of now we have to add a @DGSTypeResolver for each type that we want to resolve.

If we have many types and they all behave the same way it becomes cumbersome to add a new one everytime we add a new interface/union.

Describe Preferred Solution

Allow somehow to costumize the default type resolver that uses the class name or provide one that is used as fallback.

Describe Alternatives

esfomeado avatar Aug 13 '24 13:08 esfomeado

@esfomeado could you please share example code block that would explain the use of @DGSTypeResolver becoming cumbersome?

mrvaruntandon avatar Sep 17 '24 08:09 mrvaruntandon

@mrvaruntandon Creating a single @DGSTypeResolver is not cumbersome.

The issue is that you have to create one per interface that you have. So if you have thousands of interfaces you have to create thousands of type resolvers.

esfomeado avatar Sep 17 '24 12:09 esfomeado

Now that DGS is integrated with Spring GraphQL is possible to create a GraphQlSourceBuilderCustomizer and set a default type resolver like for instance a ClassNameTypeResolver.

The issue is that DGS on DgsGraphQLSourceBuilder doesn´t do anything with this type resolver. Check for instance the DefaultSchemaResourceGraphQLSourceBuilder, there they set the default type resolver on the runtimeWiring as expected.

The same should be possible on DGS. This way I could set a default type resolver and get rid of the @DGSTypeResolver

esfomeado avatar Jan 09 '25 12:01 esfomeado

Closing as this should be addressed by https://github.com/Netflix/dgs-framework/pull/2145. Feel free to reopen or file a new issue if not.

jjacobs44 avatar Apr 07 '25 16:04 jjacobs44