spring-projects / spring-graphql

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

Concrete types of union and interface fields should not be skipped if concrete use elsewhere provides more information #962

Closed rstoyanchev closed 5 months ago

rstoyanchev commented 5 months ago

When SchemaMappingInspector resolves union and interface type to concrete types, and cannot resolve the corresponding Java classes, it should not report them as skipped immediately because there may be other places where the concrete types are used that provide the Java class information.

For example, here only Photo should be reported as skipped:

type Query {
    search: [SearchResult]
    article(id: ID): Article
}

union SearchResult = Article | Photo

type Photo {
    height: Int
    width: Int
}

type Article {
    content: String
}

Given:

@Controller
class SearchController {

    @QueryMapping
    List<Object> search() {
        // ...
    }

    @QueryMapping
    Article article(@Argument Long id) {
        // ...
    }
}