bug: @DgsCodeRegistry not applied if bean is wrapped by Spring proxy
Expected behavior
A method annotated with @DgsCodeRegistry in a Spring bean that is wrapped by a Spring CGLIB proxy should be applied.
Actual behavior
The method is ignored an no application of the @DgsCodeRegistry takes place
Root Cause
This issue is the used way of iterating over the methods in the bean at https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L220 This is not supporting beans wrapped by a proxy which in turn makes the code to miss the annotation. The code should use the same procedure as done in other places of the class like https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L390-L392
Additionally be aware that the same issue is likely also found at
- https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L130
- https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L201
- https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L236
- https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L413
Thanks for reporting this issue. Will investigate. If you are able to could you also share an example to reproduce? Thanks!
On Wed, Jul 20, 2022 at 9:51 AM Georg Friedrich @.***> wrote:
Expected behavior
A method annotated with @DgsCodeRegistry in a Spring bean that is wrapped by a Spring CGLIB proxy should be applied. Actual behavior
The method is ignored an no application of the @DgsCodeRegistry takes place Root Cause
This issue is the used way of iterating over the methods in the bean at https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L220 This is not supporting beans wrapped by a proxy which in turn makes the code to miss the annotation. The code should use the same procedure as done in other places of the class like https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L390-L392
Additionally be aware that the same issue is likely also found at
https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L201
https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L236
https://github.com/Netflix/dgs-framework/blob/fe6ca59c04d074a4c3f5dffc2aeceb3e8aeaf4df/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/DgsSchemaProvider.kt#L487
— Reply to this email directly, view it on GitHub https://github.com/Netflix/dgs-framework/issues/1163, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ5JPXIDKYUZFSDOBKNHBBLVVAVBDANCNFSM54EMK2BA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Please see the following project: bug.zip
Usage Instructions
When running the application it currently logs ~~~~~~~~~~ This will be called and logged even though it should not! but this shouldn't happen. Instead it should log ########## This will never be called and logged even though it should! for the 4 different extensions of the DGS framework.
And finally if everything works correct, it should be possible to remove the schema.graphqls file, as there is a @DgsTypeDefinitionRegistry which defines the same schema.
You can easily switch the behaviour by commenting the line 11 in the AnnotationAspect.kt