Skip to content

Commit

Permalink
change sitemap service pageSize, serialize getStaticPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
addy-pathania committed Sep 15, 2023
1 parent d1f7455 commit 1c84f9e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ query ${usesPersonalize ? 'PersonalizeSitemapQuery' : 'DefaultSitemapQuery'}(
$language: String!
$includedPaths: [String]
$excludedPaths: [String]
$pageSize: Int = 10
$pageSize: Int = 100
$after: String
) {
site {
Expand Down Expand Up @@ -86,7 +86,7 @@ interface SiteRouteQueryVariables {
/** common variable for all GraphQL queries
* it will be used for every type of query to regulate result batch size
* Optional. How many result items to fetch in each GraphQL call. This is needed for pagination.
* @default 10
* @default 100
*/
pageSize?: number;
}
Expand Down Expand Up @@ -223,21 +223,24 @@ export abstract class BaseGraphQLSitemapService {
formatStaticPath: (path: string[], language: string) => StaticPath
) {
const paths = new Array<StaticPath>();
await Promise.all(
languages.map(async (language) => {
if (language === '') {
throw new RangeError(languageEmptyError);
}
debug.sitemap('fetching sitemap data for %s %s', language, siteName);
const results = await this.fetchLanguageSitePaths(language, siteName);
const transformedPaths = await this.transformLanguageSitePaths(
results,
formatStaticPath,
language
);
paths.push(...transformedPaths);
})
);

for (const language of languages) {
if (language === '') {
throw new RangeError(languageEmptyError);
}

debug.sitemap('fetching sitemap data for %s %s', language, siteName);

const results = await this.fetchLanguageSitePaths(language, siteName);
const transformedPaths = await this.transformLanguageSitePaths(
results,
formatStaticPath,
language
);

paths.push(...transformedPaths);
}

return paths;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ describe('GraphQLSitemapService', () => {
.post(
'/',
(body) =>
body.query.indexOf('$pageSize: Int = 10') > 0 && body.variables.pageSize === undefined
body.query.indexOf('$pageSize: Int = 100') > 0 &&
body.variables.pageSize === undefined
)
.reply(200, sitemapDefaultQueryResult);

Expand Down

0 comments on commit 1c84f9e

Please sign in to comment.