Skip to content
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

Unable to union MutationResolver and SubscriptionResolver in one class #766

Open
bostandyksoft opened this issue Oct 26, 2023 · 3 comments
Labels

Comments

@bostandyksoft
Copy link

Since update to 3.1.0 version (previous was 13.0.2)

Description

There is class, that union Mutation and Subscription resolver interfaces

@Component
public class UserAttributeMutation implements GraphQLMutationResolver, GraphQLSubscriptionResolver {

Expected behavior

FieldResolverScanner can find all methods

Actual behavior

FieldResolverScanner resolves only subscription method

Steps to reproduce the bug

It happens because there in following method

private fun getAllMethods(search: Search): List<Method> {
       val type = search.type.unwrap()
       val declaredMethods = type.declaredNonProxyMethods
       val superClassesMethods = ClassUtils.getAllSuperclasses(type).flatMap { it.methods.toList() }
       val interfacesMethods = ClassUtils.getAllInterfaces(type).flatMap { it.methods.toList() }

       return (declaredMethods + superClassesMethods + interfacesMethods)
           .asSequence()
           .filter { !it.isSynthetic }
           .filter { !Modifier.isPrivate(it.modifiers) }
           // discard any methods that are coming off the root of the class hierarchy
           // to avoid issues with duplicate method declarations
           .filter { it.declaringClass != Object::class.java }
           // subscription resolvers must return a publisher
           .filter { search.source !is GraphQLSubscriptionResolver || resolverMethodReturnsPublisher(it) }
           .toList()
   }

was added new filter
.filter { search.source !is GraphQLSubscriptionResolver || resolverMethodReturnsPublisher(it) }

So, all methods, that not return Publisher are ignored

@oryan-block
Copy link
Collaborator

Related to: #756

@bostandyksoft
Copy link
Author

Hi. What about this bug?

@oryan-block
Copy link
Collaborator

No updates yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants