Closed warmfire540 closed 9 months ago
YAY! someone from SO helped me out
Apparently the problem is with filter fields which are not included in the result. And the reason is the way HC builds the query when combined with AM - projection first (using explicit mapping, i.e. include only the specified fields), then filter. While as I understand, w/o AM they use filter first, then projection. That's why the manual Select approach works. Or because in manual approach you include all the fields in the select. Remove AM explicit expansion or do not use AM or wait HC to resolve it (if they can and willing to). – Ivan Stoev
by adding the fields explicitly in the SELECT, I don't get an exception:
{
sites(
where: { and: [{ disabled: { eq: 0 }, type: { id: { in: [1, 3] } } }] }
) {
id
name
disabled
type {
id
}
}
}
While I don't need those fields returned, these is a small API so it won't hurt. Is there a way to make it all work w/o needing to include them in the projection?
Closing as a duplicate of #5079.
Is there an existing issue for this?
Product
Hot Chocolate
Describe the bug
I've added AutoMapper to our HC 12 + EF Core 7 project to complicate things a bit more. After lots of self reflection I finally got everything setup and projections / overfetching working by following this issue #4724 and a few others. Maybe my issue is related to some of the last minute warnings in the last comment?
My present issue is that sometimes filtering is not translated the way I'd expect and instead I get an Exception from EF.
Steps to reproduce
Project Setup
My DTO
My exposed Graph entity
AutoMapper profile
Query
Issues
Here's 2 working queries
results
same as above
sql
However if I filter on the
disabled
property - I get an exceptionI'm not too sure what's different here - I would expect the
Where
to be something likeWhere(i => i.Disabled == __p_0)
I updated the
ISiteService
code to use.Map
instead of.ProjectTo
and no queries workI now get
If I don't use AutoMapper or the HC extension and manually resolve the object, it works:
Any help is appreciated! The end goal would be to use HC, EF Core, and AutoMapper. Ideally AutoMapper is just doing the object translation, I trust HC to do projections/selections/filtering since it was doing that just fine before I added AM. I get that the extension though passes the projection on to AM, I could change that if needed and not use the extension by HC.
Relevant log output
No response
Additional Context?
resources I've considered
Version
12.16.0