Skip to content

Unable to union MutationResolver and SubscriptionResolver in one class #766

Open
@bostandyksoft

Description

@bostandyksoft

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

Activity

oryan-block

oryan-block commented on Nov 9, 2023

@oryan-block
Collaborator

Related to: #756

bostandyksoft

bostandyksoft commented on Mar 19, 2024

@bostandyksoft
Author

Hi. What about this bug?

oryan-block

oryan-block commented on Mar 19, 2024

@oryan-block
Collaborator

No updates yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Unable to union MutationResolver and SubscriptionResolver in one class · Issue #766 · graphql-java-kickstart/graphql-java-tools