-
-
Notifications
You must be signed in to change notification settings - Fork 804
Description
Product
Hot Chocolate
Version
15.1.12
Link to minimal reproduction
https://github.com/1rre/HotChocolateArrayLengthBugReproduction
Steps to reproduce
Run program in reproduction repo & check generated schema - the type of numberOfAuthors is ListFilterInputTypeOfAuthorFilterInput when it should be IntOperationFilterInput:
input BookFilterInput {
and: [BookFilterInput!]
or: [BookFilterInput!]
numberOfAuthors: ListFilterInputTypeOfAuthorFilterInput
AuthorsCount: IntOperationFilterInput
title: StringOperationFilterInput
}What is expected?
The type of numberOfAuthors should be IntOperationFilterInput
What is actually happening?
The type of book.Authors.Length is captured as the type of underlying array (Author[]) rather than an int as it should be. The current workaround for this is to first cast to an ICollection then use count.
This is because Array.Length is actually a UnaryExpression rather than a PropertyExpression, and so FilterInputTypeDescriptor.Field reads through the UnaryExpression and reads the field as Book.Authors, rather than Author[].Length. This will need special handling to check whether the unary expression is ArrayLength.
Note that cast expressions are also UnaryExpression - I'm not sure if this is intentional, but I would assume that the reading through of UnaryExpression is for things like negative etc. and any type casts in .Field() should also influence the type of filter HotChocolate creates, which it doesn't seem to currently?
Relevant log output
Additional context
No response