Skip to content

BUG: Type mapper not calling first output ref #519

Open
@IceBlizz6

Description

@IceBlizz6

I believe i may have found an issue with type mappers.
I created a reproduction below.

public class DummyTypeMapper implements TypeMapper {
    @Override
    public GraphQLOutputType toGraphQLType(AnnotatedType javaType, Set<Class<? extends TypeMapper>> mappersToSkip, TypeMappingEnvironment env) {
        mappersToSkip.add(this.getClass());
        GraphQLOutputType resolvedType = env.operationMapper.toGraphQLType(javaType, mappersToSkip, env);
        System.out.println("Output: " + resolvedType);
        return resolvedType;
    }

    @Override
    public GraphQLInputType toGraphQLInputType(AnnotatedType javaType, Set<Class<? extends TypeMapper>> mappersToSkip, TypeMappingEnvironment env) {
        mappersToSkip.add(this.getClass());
        GraphQLInputType resolvedType = env.operationMapper.toGraphQLInputType(javaType, mappersToSkip, env);
        System.out.println("Input: " + resolvedType);
        return resolvedType;
    }

    @Override
    public boolean supports(AnnotatedElement element, AnnotatedType type) {
        return true;
    }
}
public class SearchService {
    @GraphQLQuery
    public String search1(String key) {
        throw new Error();
    }

    @GraphQLQuery
    public String search2(String key) {
        throw new Error();
    }
}
GraphQLSchema schema = new GraphQLSchemaGenerator()
                .withOperationsFromSingleton(new SearchService())
                .withTypeMappers(new DummyTypeMapper())
                .generate();

The output here will be:

Output: GraphQLScalarType{name='String', .....
Input: GraphQLTypeReference{name='String'}
Output: GraphQLTypeReference{name='String'}
Input: GraphQLTypeReference{name='String'}

Service defines 2 operations where both return string and inputs a string.
So there are 4 type references here, but mapper only picks up 3.
It seems like 1 output reference is always skipped.

Similarly if we try this with only 1 operation:

Output: GraphQLScalarType{name='String', ...
Input: GraphQLTypeReference{name='String'}

(no type output references are called)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions