Understanding SqlResolvers and Batching in Effect TypeScript

I'm trying to understand how to best use SqlResolvers. I have this function that tries to get data from different tables concurrently.

If I omit the { batching: true } in either place, then there will be many requests for each challengeId. why is this? is there any way to mark an entire function/span like this as batched?

      const getAllChallenges = Effect.fn(span("getAllChallenges"))(
        function*(ids: ReadonlyArray<ChallengeId>) {
          return yield* Effect.forEach(
            ids,
            (id) =>
              Effect.zip(
                GetChallengeWithCheckInSchedule.execute(id),
                GetChallengeRequirements.execute(id),
                { concurrent: true, batching: true }
              ).pipe(
                Effect.andThen(([challengeOption, reqs]) =>
                  Option.map(challengeOption, (challenge) =>
                    ChallengeFull.make({
                      ...challenge,
                      requirements: reqs,
                      defaultCheckInSchedule: challenge.schedule
                    }))
                )
              ),
            { concurrency: 10, batching: true }
          )
        }
      )
Was this page helpful?