Filter on an Array of reference objects

Sebastian,
I have a post style content that has an array of referenced Author objects.
I am having problems filtering the posts based on the GUID Id of the Author object.
Is that possible? at the moment?
Thanks
Marcus

Hi,

yes it is possible. Just use the Equals filter.

?$filter=data/authors/iv eq '<AUTHOR-ID>'

Hi, @Sebastian !
If we assume the example above, is it possible to query Authors basing on number of Posts referencing at Author?
f.e. I want to know what Authors did not made any Posts at all.
But the problem is the link is from the Post at some Author. I’ve found a field in GQL queries which return all the entities referencing at my entity. I.E. in example above I can query all the Authors first and see the Post referencing at them. But I can’t make any filter on the Post referencing on the Authors.

Or I can first get all the Authors and then on App side remove from result all having no Posts referencing at them. But this is 2 requests for me and may lead to some performance issues…

How do you think, are there any appropriate or even “out-of-box” solutions for such situations?

Hi.

this is not possible direclty. You can …

  • via GraphQL: Fetch all authors the referencing posts and then filter out client side.
  • via Webhook or Scripting: Maintain a normalized field with the number of blog posts per author.
  • Change the reference direction, so that each author has a list of blog posts and then use the empty operator.
  • Fetch all authors and blog posts in parallel or via GraphQL and then solve it client side.

I would not expect any big performance issues, it is only 2 database calls instead of one.

1 Like