django-restql icon indicating copy to clipboard operation
django-restql copied to clipboard

Querying data not working as expected

Open mario-maistra opened this issue 2 years ago • 1 comments

While trying out querying data on the playground, I could not get the excepted result. For example, I chose Course model on the playground and tried to query by book ID, like this: { id, name, code, books(id:3) { id, title, author, genre { id, title, description } } }

It returns all courses. But if I try to query by course id, like this: (id:1) { id, name, code, books { id, title, author, genre { id, title, description } } }

It works as excepted. Tried it out on some of the offered models, but I could not get consistent result...sometimes it works as excepted, and in some cases (like this one) it does not. How does this exactly work?

mario-maistra avatar Dec 16 '21 15:12 mario-maistra

The behavior in the first query happens because books is a many-to-many field. However, it's quite unlikely that the issue lies with django-restql as django-restql simply propagates the filtering responsibility to the django filtering backend. It would depend on how the the filters for the many-to-many field were defined (if any) and which backend was used.

resurrexi avatar Jan 07 '22 05:01 resurrexi