Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Realm Graphql query with MongoDB operators

When mongdb realm creates the default graphql queries, is there a way to use an operator, such as $regex with the query? I cannot seem to get it to work.
One of the automatically generated query for movies is this:
movies(
limit: Int = 100
sortBy: MovieSortByInput
query: MovieQueryInput
): [Movie]!

This works in the shell:
db.movies.find({“title”:{$regex:“girl”}})

How would I do this with the above query?

Hi Fred – You aren’t able to feed MongoDB syntax directly to the GraphQL API, but we do generate a set of resolvers to make querying simpler. However, we don’t generate anything for Regex at this point and recommend that you define a custom resolver for this.

I figured. Thanks Drew.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.