Skip to content

feat: add retry strategy for api-rest category #8295

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

Merged
merged 6 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ async function deleteItem() {
try {
const restOperation = del({
apiName: 'myRestApi',
path: 'items/1'
path: 'items/1',
retryStrategy: {
strategy: 'no-retry'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would also add comment to these on what default will be somethign like

Suggested change
strategy: 'no-retry'
strategy: 'no-retry' // This overrides default automatic retry strategy

},
});
await restOperation.response;
console.log('DELETE call succeeded');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ import { get } from 'aws-amplify/api';
async function getItem() {
try {
const restOperation = get({
apiName: 'myRestApi',
path: 'items'
});
apiName: 'myRestApi',
path: 'items'
retryStrategy: {
strategy: 'no-retry'
},
});
const response = await restOperation.response;
console.log('GET call succeeded: ', response);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ async function postItem() {
body: {
message: 'Mow the lawn'
}
}
},
retryStrategy: {
strategy: 'no-retry'
},
});

const { body } = await restOperation.response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,24 @@ import outputs from '../amplify_outputs.json';

const amplifyConfig = parseAmplifyConfig(outputs);

Amplify.configure({
...amplifyConfig,
API: {
...amplifyConfig.API,
REST: outputs.custom.API,
Amplify.configure(
{
...amplifyConfig,
API: {
...amplifyConfig.API,
REST: outputs.custom.API,
},
},
});
{
API: {
REST: {
retryStrategy: {
strategy: 'no-retry'
},
}
},
}
);
```
</InlineFilter>

Expand All @@ -251,13 +262,24 @@ import outputs from '@/amplify_outputs.json';

const amplifyConfig = parseAmplifyConfig(outputs);

Amplify.configure({
...amplifyConfig,
API: {
...amplifyConfig.API,
REST: outputs.custom.API,
Amplify.configure(
{
...amplifyConfig,
API: {
...amplifyConfig.API,
REST: outputs.custom.API,
},
},
});
{
API: {
REST: {
retryStrategy: {
strategy: 'no-retry'
},
}
}
}
);
```
</InlineFilter>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,24 @@ import outputs from '../amplify_outputs.json';

const amplifyConfig = parseAmplifyConfig(outputs);

Amplify.configure({
...amplifyConfig,
API: {
...amplifyConfig.API,
REST: outputs.custom.API,
Amplify.configure(
{
...amplifyConfig,
API: {
...amplifyConfig.API,
REST: outputs.custom.API,
},
},
});
{
API: {
REST: {
retryStrategy: {
strategy: 'no-retry'
},
}
}
}
);
```
</InlineFilter>

Expand All @@ -234,13 +245,24 @@ import outputs from '@/amplify_outputs.json';

const amplifyConfig = parseAmplifyConfig(outputs);

Amplify.configure({
...amplifyConfig,
API: {
...amplifyConfig.API,
REST: outputs.custom.API,
},
});
Amplify.configure(
{
...amplifyConfig,
API: {
...amplifyConfig.API,
REST: outputs.custom.API,
},
},
{
API: {
REST: {
retryStrategy: {
strategy: 'no-retry'
},
}
}
}
);
```
</InlineFilter>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ async function updateItems() {
path: 'items/1',
options: {
body: Item
}
},
retryStrategy: {
strategy: 'no-retry'
},
});
const response = await restOperation.response;
console.log('PUT call succeeded: ', response);
Expand Down