title: N+1 queries in AWS AppSync
body: <p>When using AWS AppSync with lambda data sources you can encounter N+1 query problem. </p>
  
  <p>Basically when you have individual field resolver on your type and your query returns an array of those types you field resolver lambda will be called N times.</p>
  
  <p>AWS introduces BatchInvoking lambdas in resolvers to combat this problem. Here you can read more about the problem and their solution: <a href="https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html#advanced-use-case-batching" rel="noreferrer">https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html#advanced-use-case-batching</a></p>
  
  <p>However, their solution is not working. BatchInvoking lambdas are limited to only 5 events (this is not stated in documentation). It is a slight improvement to the N+1 problem (it makes it N/5+1), but I think it is not enough as more complex queries tend to execute for a very long time and require more lambda invocations.</p>
  
  <p>So my question is how do you deal with this problem? Is there any better solution to this?</p>