amplify-codegen-ui
amplify-codegen-ui copied to clipboard
feat: amplify js v6 api support
Problem
we are updating our renderers to support the new amplify js v6 updates to the API category.
Solution
The changes involve updating the import statement to
import { generateClient } from "aws-amplify/api";
const client = generateClient();
and api graphql operations to
const response = await client.graphql({
query: mutations.createTodo,
variables: {
input: {
name: `Name ${Date.now()}`,
description: `Description ${Date.now()}`,
},
},
});
Additional Notes
The change in the api code generation is triggered by passing in a dependencies object to the renderer. In the current state if the dependencies object as a 'aws-amplify' dependency that has a value of >=6.0.0, the v6 API code will be generated. Otherwise, the code will continue to generate the current v5 compatible code.
Links
Ticket
GitHub issue:
Other links
Verification
Manual tests
Automated tests
- [x] Unit tests added/updated
- [ ] E2E tests added/updated
- [ ] N/A - (provide a reason)
- [ ] deferred - (provide GitHub issue for tracking)
Housekeeping
- [x] No non-essential console logs
- [x] All new files contain license notice
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.