Apongo - create optimal Mongo joins for Apollo queries


For those of you (like myself) who love the combination of Meteor/Apollo/Mongo, you may find my new project useful:

It allows your GraphQL resolvers to generate a single Mongo query which performs joins to other collections. It’s really handy when you need to paginate data from multiple collections while sorting on an arbitrary field.

It exposes an Apollo directive so that you can make your joins explicit:

type User {
  company: Company @apongo(lookup: { collection: "companies", localField: "companyId", foreignField: "_id" })

Hope you find it useful.


Very cool! Maybe something we could use in Vulcan, especially since a lot of the resolvers for the “join” fields are auto-generated.

1 Like

Hi Sacha.

I’ve love you to give it a try. I’ve just fixed a silly bug that slipped though that would stop it even compiling on most projects, and I’ve overhauled the documentation - hopefully it makes more sense now.

I’ve also started to add in some unit tests, so the code there should also act as an example.

Nice one, @tarmes!

Have you seen SparrowQL? It’s something I made for generating the whole pipeline based on a query, sort, etc. and it looks pretty similar. I definitely have to read through your code - maybe I’ll incorporate something into Sparrow :smile:

Hi radekmie,

I didn’t know about Sparrow. Looks nice.

There’s obviously a similarity in that we’re both generating a pipeline to do the lookups, however there’s a big difference in that I’m generating the lookups specifically for a given Apollo GraphQL request. Apongo analyses the requested fields and generates the required pipeline automatically.

Sparrow is independent of anything else, whereas Apongo is specially designed to help tie Apollo and Mongo together, hence the silly name :slight_smile:


That’s why there’s an additional package: sparrowql-graphql. Take a look at the tests.