Complex Graphql Query with Mongodb?

I tried to use Meteor Apollo and Vue.
But I have problem on Graphql Query in complex mongo query such as:

  • Operator: $gt, $ne…, OR, AND, limit, sort …
  • Aggregate: …

Have any package or helper to do this???

Maybe not what you are looking for, but I personally would only add Apollo into my Meteor + Vue stack if I started to have other data sources in my app, other than MongoDB. Otherwise you have to do at least 3x the work. Takes some of the fun & simplicity out of Meteor, haha.

If you still want to do it, you have to 1st write your MongoDB query, just like you would in Meteor, so probably with the rawCollection() for advanced MongoDB queries & store that result in memory on the server. Then from that result, you can write your GraphQL schema, query, cache, etc. So much extra work.

From a Vue Method I often call an async Meteor Method on the Server with my complex MongoDB query, like Aggregate, and return the result directly to Vue’s data.

Here is a post that might be helpful about using rawCollection()

And you probably already have a reference for this, but here is a walk through on Apollo. Use rawCollections() in place of the MongoDB connection step. If you really wanted, because Meteor is flexible, you could follow the Apollo Tutorial exactly with a separate HTTP connection to MongoDB, but you probably wouldn’t want to go that route. If you are just playing around with Apollo to test it out, have fun, and bet you’ll come to the same conclusion about it’s extra complexity.

1 Like

@mullojo, thanks for your quick reply.
Yes It is difficult to create Graphql Query for complex mongo query.
Could you share Meteor Vue sample app?

Incorrect link walk through on Apollo???

My current app is not an open-source app, but I could help you with a query if you share more info. I’m thinking of creating an open-source app with Meteor + Vue for the community to learn from, but be a while before I’ve got that going.

There are probably some useful reference / demo app examples out there. I’ve explored @akryum’s Apollo integration before. Check out those repos for examples/demos.

thanks again, Use Meteor Methods is easy than Apollo grapql.
But i would like to try (Leaning)

Now I would like to try build Restaurant App (Online).
Support multi company register to use it, but don’t have more experience about online app.
(Use to offline app before)