mirror of
https://github.com/AnimeThemes/animethemes-web.git
synced 2026-07-11 01:24:31 +02:00
fix: Fixed pagination not working with nullable responses (e.g. 403 errors) (#214)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user