fix: Fixed pagination not working with nullable responses (e.g. 403 errors) (#214)

This commit is contained in:
Mani
2024-05-18 01:35:40 +02:00
committed by GitHub
parent 8e7fc142eb
commit 4b7840ba1b
+5
View File
@@ -308,6 +308,11 @@ export function apiResolver(config: ApiResolverConfig): GraphQLFieldResolver<Rec
while (nextUrl) {
const json = await fetchJson(nextUrl, { headers }) as Record<string, unknown> & { links: { next: string } };
context.apiRequests++;
if (!json) {
return null;
}
results.push(...transformer(extractor(json, parent, args), parent, args) as Array<unknown>);
devLog.info(`Collecting: ${url}, Got ${results.length}`);
nextUrl = !args.limit ? json.links.next : null;