GraphQL query and filter


#1

Hi Sebastian,

I have a few questions about Squidex filter on GraphQL request.

  1. From the doc in /api/graphql, It seem like Squidex is using OData filter on top of GraphQL. Is Squidex also support normal GraphQL query ? If it supported, Could I ask for the example queries please ? I tried by myself and it’s not working.

  2. Does Squidex GraphQL support $expand param ? I want to filter the content from the ref object. eg. get users from company “ABC”.

  3. How to exclude the content with empty ref object ? eg. get users with any companies except users without selected company. I tried some methods like “ne null” and “/$count gt 0” but it didn’t work.

  4. How to filter the text with wildcard ? eg. input “Alb” and then it returns users with “Alb” in their name.

Thank you


#2

Hi

  1. GraphQL uses OData as filter system. The reason is that I did not want to write a custom (or second) query system. You can find examples here: https://docs.squidex.io/guides/02-api#usdfilter. What is a normal GraphQL query?

  2. No, it does not make sense with GraphQL I think. Do you have a reference from users to company? If yes you have to take the company id and use a simple eq filter `$filter=company eq ‘123…’``

  3. Good question. Have to try it myself.

  4. See the link in first answer. contains is your friend.


#3

I am working on a custom empty function. Should be ready soon.


#4

I have pushed the empty function. It works for string, assets and references.

The syntax is $filter=empty(data/firstName/iv)


#5

Thank you very much. I’m very appreciated for your help.


#6

The empty filter works great. Btw I still cannot use simple eq filter on ref object.

eg.
queryUsersContents
(filter: " data/company/iv/data/name/iv eq ‘123’ ")

I got the error “Error trying to resolve queryUsersContents.”. I also went to the logfile for more information about the error but didn’t find anything logged.


#7

You cannot traverse the references when you write your odata queries.