Skip to content

Commit

Permalink
fix: pluralize table name when building join table index query
Browse files Browse the repository at this point in the history
  • Loading branch information
awinberg-aws committed Aug 12, 2023
1 parent d066faa commit 96059ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10040,7 +10040,7 @@ import {
getClass,
listStudentClasses,
listStudents,
studentClassByClassId,
studentClassesByClassId,
} from \\"../graphql/queries\\";
import { API } from \\"aws-amplify\\";
import {
Expand Down Expand Up @@ -10251,12 +10251,12 @@ export default function ClassUpdateForm(props) {
const linkedStudents = record
? (
await API.graphql({
query: studentClassByClassId,
query: studentClassesByClassId,
variables: {
classId: record.id,
},
})
).data.studentClassByClassId.items.map((t) => t.student)
).data.studentClassesByClassId.items.map((t) => t.student)
: [];
setLinkedStudents(linkedStudents);
setClassRecord(record);
Expand Down Expand Up @@ -11249,7 +11249,7 @@ import {
import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\";
import { fetchByPath, validateField } from \\"./utils\\";
import {
cPKTeacherCPKClassByCPKTeacherSpecialTeacherId,
cPKTeacherCPKClassesByCPKTeacherSpecialTeacherId,
getCPKTeacher,
listCPKClasses,
listCPKProjects,
Expand Down Expand Up @@ -11498,12 +11498,12 @@ export default function UpdateCPKTeacherForm(props) {
const linkedCPKClasses = record
? (
await API.graphql({
query: cPKTeacherCPKClassByCPKTeacherSpecialTeacherId,
query: cPKTeacherCPKClassesByCPKTeacherSpecialTeacherId,
variables: {
cPKTeacherSpecialTeacherId: record.specialTeacherId,
},
})
).data.cPKTeacherCPKClassByCPKTeacherSpecialTeacherId.items.map(
).data.cPKTeacherCPKClassesByCPKTeacherSpecialTeacherId.items.map(
(t) => t.cpkClass
)
: [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
GenericDataField,
GenericDataSchema,
} from '@aws-amplify/codegen-ui';
import { plural } from 'pluralize';
import {
getRecordsName,
getLinkedDataName,
Expand Down Expand Up @@ -1083,7 +1084,7 @@ export const buildGetRelationshipModels = (
const joinTableThisModelName = fieldConfigMetaData.relationship.relatedModelFields[0];
const joinTableThisModelFields =
extractAssociatedFields(joinTableMetadata!.fields[joinTableThisModelName]) || [];
const joinTableIndexedQuery = `${lowerCaseFirst(relatedJoinTableName)}By${joinTableThisModelFields
const joinTableIndexedQuery = `${plural(lowerCaseFirst(relatedJoinTableName))}By${joinTableThisModelFields
.map(capitalizeFirstLetter)
.join('And')}`;
importCollection.addGraphqlQueryImport(joinTableIndexedQuery);
Expand Down

0 comments on commit 96059ad

Please sign in to comment.