graphql

hlship 2020-06-21T17:34:46.192100Z

The general solution to n+1 in GraphQL is to use a data loader; we have an internal one that we hope to release as open source in the future, and there's also Superlifter: https://github.com/oliyh/superlifter

2020-06-21T17:40:52.197400Z

I think I've so far only hit n+1 once in our graphql usage, and what I did was have the parent object resolver build a cache, and add the cache to the context, and then the field resolver checks for values in the cache. So if the field is being resolved on its own, no cache and it goes to the database, if the field is being resolved as part of a collection under the parent, it will find itself in the cache the parent built.