Skip to content

Commit

Permalink
fix: add form datamodel to requiredDataModels for renderComponentOnly (
Browse files Browse the repository at this point in the history
…#815)

Co-authored-by: Justin Shih <jushih@amazon.com>
  • Loading branch information
Jshhhh and Justin Shih authored Dec 2, 2022
1 parent 609ffc2 commit f0d74e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,13 @@ describe('amplify form renderer tests', () => {
'datastore/project-team-model',
);

const teamAlias = importCollection.importAlias.get(ImportSource.LOCAL_MODELS)?.get('Team');
const teamAlias = importCollection.getMappedAlias(ImportSource.LOCAL_MODELS, 'Team');

const includesTeam = requiredDataModels.includes('Team');
const includesMember = requiredDataModels.includes('Member');
expect(teamAlias).toBe('Team0');
expect(includesTeam).toBe(true);
expect(includesMember).toBe(true);
expect(importCollection).toBeDefined();
});

Expand Down
1 change: 1 addition & 0 deletions packages/codegen-ui-react/lib/forms/react-form-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export abstract class ReactFormTemplateRenderer extends StudioTemplateRenderer<

// add model import for datastore type
if (dataSourceType === 'DataStore') {
this.requiredDataModels.push(dataTypeName);
modelName = this.importCollection.addImport(ImportSource.LOCAL_MODELS, dataTypeName);
}

Expand Down

0 comments on commit f0d74e5

Please sign in to comment.