It seems like this should be fairly obvious, but I cannot get the logical AND
operator to work with GraphQL.
I couldn’t find specific GraphQL docs, but the standard REST docs seem to be straightforward so I just moved the syntax over to GraphQL.
The documentation says that AND
is used implicitly - I take this to mean that I don’t have to write out _and
, and that all that is required is to enclose multiple conditions within an array. However, when I attempt this I get an error.
The AND
breaks:
What am I missing here?
Are there any GraphQL docs out there?
Thanks.
System Information
-
3.2.5:
-
Win 10 Pro:
-
postgres:
-
12.18.2:
-
6.9:
There is not yet and we do plan to add them but I do believe there is some fundimental issues with the complex queries within GraphQL at the moment. We have a database layer refresh set for this quarter ( Database layer (v4) - Roadmap | Product Roadmap ) that is also planning to implement some critical changes to how we handle GQL vs REST and our intent is to make their usage much easier.
I’ll try and do some testing this coming week to see if I can provide some useful examples for you, but for the moment my suggestion is using REST instead.
1 Like
Interesting, and thanks for answering.
I did end up figuring out the implicit AND - essentially these are listed as object properties not within an array (OR syntax). In this sense, the REST syntax is slightly different than the GraphQL syntax.
My only issue now is using a query with multiple OR clauses. Currently, only a single OR clause can be used in a complex query using GraphQL. My ecommerce use case does require complex filtering such as:
Category A
AND
OR Brand A, Brand B
AND
OR Style A, Style B
In English - show me Sneakers made by Nike or Reebok in high top or mid top
Perhaps this example is part of the issues you mentioned.
I find Strapi very interesting and understand there are many improvements underway.
I will take a look at using REST