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] Fix custom retryStrategy #1749

Merged
merged 5 commits into from
Feb 27, 2024
Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ Our versioning strategy is as follows:
* `[templates/nextjs-sxa]` Fix feature `show Grid column` in Experience Editor. ([#1704](https://github.com/Sitecore/jss/pull/1704))
* `[sitecore-jss-nextjs] [templates/nextjs-xmcloud]` SDK initialization rejections are now correctly handled. Errors should no longer occur after getSDK() promises resolve when they shouldn't (for example, getting Events SDK in development environment) ([#1712](https://github.com/Sitecore/jss/pull/1712) [#1715](https://github.com/Sitecore/jss/pull/1715) [#1716](https://github.com/Sitecore/jss/pull/1716))
* `[sitecore-jss-nextjs]` Fix redirects middleware for working with absolute url where is using site language context ([#1727](https://github.com/Sitecore/jss/pull/1727)) ([#1737](https://github.com/Sitecore/jss/pull/1737))
* `[sitecore-jss]` Retry policy to handle transient network errors. Users can pass `retryStrategy` to configure custom retry config to the services. They can customize the error codes and the number of retries. It consist of two functions shouldRetry and getDelay. To determine the back-off time, we employ an exponential strategy with a default factor of 2.([#1731](https://github.com/Sitecore/jss/pull/1731)) ([#1733](https://github.com/Sitecore/jss/pull/1733)) ([#1738](https://github.com/Sitecore/jss/pull/1738))
* `[sitecore-jss]` Enable the Layout and dictionary service to use custom `retryStrategy`. ([#1749](https://github.com/Sitecore/jss/pull/1749))

### 🛠 Breaking Changes

2 changes: 2 additions & 0 deletions packages/sitecore-jss/src/i18n/graphql-dictionary-service.ts
Original file line number Diff line number Diff line change
@@ -178,13 +178,15 @@ export class GraphQLDictionaryService extends DictionaryServiceBase {
return this.options.clientFactory({
debugger: debug.dictionary,
retries: this.options.retries,
retryStrategy: this.options.retryStrategy,
});
}

return new GraphQLRequestClient(this.options.endpoint, {
apiKey: this.options.apiKey,
debugger: debug.dictionary,
retries: this.options.retries,
retryStrategy: this.options.retryStrategy,
});
}
}
2 changes: 2 additions & 0 deletions packages/sitecore-jss/src/layout/graphql-layout-service.ts
Original file line number Diff line number Diff line change
@@ -102,13 +102,15 @@ export class GraphQLLayoutService extends LayoutServiceBase {
return this.serviceConfig.clientFactory({
debugger: debug.layout,
retries: this.serviceConfig.retries,
retryStrategy: this.serviceConfig.retryStrategy,
});
}

return new GraphQLRequestClient(this.serviceConfig.endpoint, {
apiKey: this.serviceConfig.apiKey,
debugger: debug.layout,
retries: this.serviceConfig.retries,
retryStrategy: this.serviceConfig.retryStrategy,
});
}

Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ const defaultQuery = /* GraphQL */ `
`;

export interface GraphQLErrorPagesServiceConfig
extends Pick<GraphQLRequestClientConfig, 'retries'> {
extends Pick<GraphQLRequestClientConfig, 'retries' | 'retryStrategy'> {
/**
* Your Graphql endpoint
* @deprecated use @param clientFactory property instead
@@ -124,13 +124,15 @@ export class GraphQLErrorPagesService {
return this.options.clientFactory({
debugger: debug.errorpages,
retries: this.options.retries,
retryStrategy: this.options.retryStrategy,
});
}

return new GraphQLRequestClient(this.options.endpoint, {
apiKey: this.options.apiKey,
debugger: debug.errorpages,
retries: this.options.retries,
retryStrategy: this.options.retryStrategy,
});
}
}