GraphQL query string filters like "StartsWith" or "Contains"

I have generated GraphQL queries on realm app based on the schema. Generated GraphQL query has multiple filter options like _exists, _in, _gt, _lt, _nin, _gte etc.

I’m looking to fetch all the records where name starts with “xyz” or string contains any given word. Can anyone suggest how to apply such filters?

Hi Vivek – For this case we would recommend creating a custom resolver that leverages MongoDB’s Text Search.

1 Like

thanks for the response Drew,

I would imagine taking the custom resolver route for any specialized functionality where I have the freedom to implement the behaviour I want. However regex pattern matching on string fields should be part of auto-generated filters.

Do you think it could be implemented as generic feature at some point in future? or, are there any risks etc in adding it to default auto-generated filters like lack of indexes?

Hi Vivek – We’re definitely considering adding a Regex pattern to our defaults but don’t have a timeline for when this would be added. This is slightly complicated by the fact that $search is becoming the recommendation for use cases like this but requires additional set-up on the cluster.

1 Like