I concur that doing this via the redwood exec script is best — but you may want to simply look into using Prisma to query or to import a service to fetch data instead of making a GraphQL query.
Then send that to the Algolia index.
That said, I think @Tobbe recently made some GraphQL query from a script and could share his solution.