Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sitecore-jss-nextjs] Reduce the amount of Edge API calls during fetch getStaticPaths #1612

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Our versioning strategy is as follows:
* `[sitecore-jss-react]` Fetch Data for FEaaS Components as part of Component SSR/SSG ([#1586](https://github.com/Sitecore/jss/pull/1590))
* `[sitecore-jss-dev-tools]` `[templates/nextjs]` `[templates/react]` Introduce "components" configuration for ComponentBuilder ([#1598](https://github.com/Sitecore/jss/pull/1598))
* `[sitecore-jss-react]` `[sitecore-jss-nextjs]` Component level data fetching(SSR/SSG) for BYOC ([#1610](https://github.com/Sitecore/jss/pull/1610))
* `[sitecore-jss-nextjs]` Reduce the amount of Edge API calls during fetch getStaticPaths ([#1612](https://github.com/Sitecore/jss/pull/1612))

### 🧹 Chores

Expand Down
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