A simpler way to add logic for filtering with logical operators #2224
Replies: 3 comments
-
Sort of (in gqlgen-sqlboiler), really like what we have now, but complex queries are not possible with the way we do it. |
Beta Was this translation helpful? Give feedback.
-
It's hard to structure and/or combinations I don't how to structure that. e.g. subqueries and things like that. Also keep in mind that you do the authorization part of the query as most important part and the user generated filter query in a AND (..generated-filter here) |
Beta Was this translation helpful? Give feedback.
-
For complex or/and queries like below I don't really like the appraoch whe have now but for simple things it's ok ;) o |
Beta Was this translation helpful? Give feedback.
-
I'm using GraphQL in Golang with gqlgen and Bun as ORM.
I'm using DDD and Clean architecture, meaning that I'm avoiding
one-size-fits-all/lock-in
solutions like Hasura, Postgraphile, DGraph and everything like that; I can (and I eventually will, no hurry) write and organize my code in such a way to achieve their features.For now I'm wondering about complex queries with filters like:
AND
,OR
,NOT
(better described here).Right now I need to think/write/test code all by myself and this certainly does not speed up production of the software I want to write.
Also, my code will almost certainly be slow, buggy and possibly all wrong as soon as I realize that I will need something extra for this feature.
After all, this is true for all software and is one of the reasons why open source was born.
After some research I noticed there are two approaches to solving the problem of GraphQL data filtering:
create all possible combinations for each field of the model (this is how ent behaves and other users suggest)
create input types that contain the model fields but also logical comparators as a possible value (like Hasura, Postgraphile and others do)
QUESTIONS
What do you think about? Pros and cons of each choice?
If we aren't using Ent as ORM (which already manages this with code generation) can we have a "global" way to map our Graphql/Gqlgen-generated structs to our domain code without manually write that logic by ourself?
Has anyone faced this problem before? @RichardLindhout?
Beta Was this translation helpful? Give feedback.
All reactions