spring-projects / spring-graphql

Spring Integration for GraphQL
https://spring.io/projects/spring-graphql
Apache License 2.0
1.52k stars 297 forks source link

Schema inspection reports skipped type when field is mapped to property with generic type #1037

Open luis22737928 opened 1 month ago

luis22737928 commented 1 month ago

Hello, I have come across the following issue... I have a controller that returns a typed class (DataRep) and in this class there is a collection of T.

Here is the schema definition:

type Genero {
    id: Int
    descripcion: String
}

type PagGenero {
    listado: [Genero]
}

Here is the controller:

@QueryMapping
public DataResp<Genero> getGenerosPag(@Argument(name = "dataReq") _GeneroDataReqInput dataReq) {
        return generoService.findByUsuarioActual(dataReq);
}

And here is the class returned DataResp:

public class DataResp<T> {
    protected List<T> listado = new ArrayList<>();

    public DataResp(List<T> listado) {
        this.listado = listado;
    }
}

Everything works fine, but the inspection report cannot recognize the type of the collection and reports Genero as a skipped type:

GraphQL schema inspection:
    Unmapped fields: {}
    Unmapped registrations: {}
    Unmapped arguments: {}
    Skipped types: [Genero]

Is there a way to make introspection recognize this mapping between the collection declared in the schema and the one returned? thank you in advance

rstoyanchev commented 1 week ago

Can you show the Query type in the schema? In other words, what the output type for the getGenerosPag query is, and how DataResp<Genero> is mapped to that.

luis22737928 commented 1 week ago

Here is the schema definition:

type Genero {
    id: Int
    descripcion: String
}

type PagGenero {
    totalFilas: Int
    filasPorPagina: Int
    numeroDePagina: Int
    totalPaginas: Int
    listado: [Genero]
    msj: String
}

extend type Query {
    getGenerosPag(dataReq: GeneroDataReqInput): PagGenero
}

The type PagGenero is assigned to the returned class DataResp< T >, where the type Genero is assigned to the parameter class T.

rstoyanchev commented 1 week ago

Okay so the issue seems to be with a field that is mapped to a property with a generic type.