leangen / graphql-spqr

Build a GraphQL service in seconds
Apache License 2.0
1.09k stars 181 forks source link

@GraphQLIgnore is ignored and produces errors. #298

Closed tufgupmi closed 4 years ago

tufgupmi commented 5 years ago

Hello,

If we have this case


public interface Category<C> extends Categorizable {
     String getCode(); 
    CategoryType getCategoryType();
}

public interface Categorizable<C extends Category> {
    @GraphQLIgnore
    C getCategory();
}

public class ServiceSubCategory  implements Category<ServiceCategory> {
  ....

   @GraphQLIgnore
     public ServiceCategory getCategory() {
        return serviceCategory;
    }
 ....
}

When the schema is build there is an error because the method getCategory launches a TypeMappingException because ServiceCategory is a generic type. But i have marked the methos as @GraphQLIgnore, so this method should be ignored when processing the schema, but it's not

To solve this i have to modifiy method buildResolvers on PublicResolverBuilder to filter methods that are annotated with @GrapohQLIgnore


    return Arrays.stream(rawType.getMethods())
          --> .filter(method -> !method.isAnnotationPresent(GraphQLIgnore.class))
                .filter(method -> isPackageAcceptable(method, rawType, params.getBasePackages()))
           .......
rmoutray-configureone commented 4 years ago

I can confirm, just ran into this same issue.