Custom query resolvers supporting the generated query input

I have a simple query resolver that finds all Documents created by a User.
e.g.

query {
  users {
    documents {
      name
    }
  }
}

Under the hood it does smth like this:

const requesterOpportunitiesResolver = (_, source) => context.services.get('mongodb-atlas').db('xxxl').collection('documents').find({ user: source._id }).toArray()

Now the question is how do I support all the filtering options that the generated documents query supports?
Manually map everything from the input to some mongodb queries??

E.g. I want smth like this:

query {
  users {
    documents (query: {tags_in: ["tag1", "tag2"]}) {
      name
    }
  }
}

Basically the way I imagine it could work is if there was a function to generate mongodb query based on input argument.

Hi! You should be able to do this by defining a “custom input type” (ex here - https://docs.mongodb.com/realm/graphql/custom-resolvers#define-the-input-type)

You would probably define the input like this:

  "bsonType": "object",
  "title": "requesterOpportunitiesResolver",
  "properties": {
    "tags_in": {
      "bsonType": "array",
       "items": 
          { 
           "bsonType": "string"
          }
      
    }
  }
}

Is this what you’re looking for?