-
Notifications
You must be signed in to change notification settings - Fork 322
Closed
Description
Using Spring GraphQL 1.0.0 with Spring Boot 2.7.0 and Java 17
When passing a single object as argument to a query that expects an array, the argument resolver creates a List<LinkedHashMap>
.
Instead it should create a List<Foo>
with a single entry.
Here's my code to reproduce the error:
Controller:
@Controller
public class BookController {
@QueryMapping
Flux<Book> books(@Argument List<BookOrdering> orderBy) {
System.out.println(orderBy.get(0).field()); // throws exception
return Flux.empty();
}
}
Classes:
public record BookOrdering(BookSort field) {
public BookOrdering {
Objects.requireNonNull(field);
}
}
public enum BookSort {
NAME,
}
public record Book(String id, String name) {
}
Schema:
type Query {
books(orderBy: [BookOrdering!]! = []): [Book!]!
}
enum BookSort {
NAME,
}
input BookOrdering {
field: BookSort!
}
type Book {
id: ID!
name: String!
}
Query:
query {
books(orderBy: { field: NAME }) {
id
}
}
Exception:
java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class com.example.demo.web.book.types.BookOrdering
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug