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

fix: use related model name instead of field in generating graphql qu… #1039

Merged
merged 4 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"check-coverage": true,
"lines": 70,
"statements": 70,
"branches": 50,
"functions": 65,
"coverageReporters": [
"json"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ import {
import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\";
import { fetchByPath, validateField } from \\"./utils\\";
import { API } from \\"aws-amplify\\";
import { listTeamIDS, listTeams } from \\"../graphql/queries\\";
import { listTeams } from \\"../graphql/queries\\";
import { createMember } from \\"../graphql/mutations\\";
function ArrayField({
items = [],
Expand Down Expand Up @@ -931,7 +931,7 @@ export default function MyMemberForm(props) {
}
const result = (
await API.graphql({
query: listTeamIDS,
query: listTeams,
variables,
})
).data.listTeamIDS.item;
Expand Down Expand Up @@ -1866,7 +1866,7 @@ import {
import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\";
import { fetchByPath, validateField } from \\"./utils\\";
import { API } from \\"aws-amplify\\";
import { listPrimaryAuthors } from \\"../graphql/queries\\";
import { listAuthors } from \\"../graphql/queries\\";
import { createBook } from \\"../graphql/mutations\\";
function ArrayField({
items = [],
Expand Down Expand Up @@ -2112,7 +2112,7 @@ export default function BookCreateForm(props) {
}
const result = (
await API.graphql({
query: listPrimaryAuthors,
query: listAuthors,
variables,
})
).data.listPrimaryAuthors.item;
Expand Down Expand Up @@ -3024,7 +3024,7 @@ import {
import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\";
import { fetchByPath, validateField } from \\"./utils\\";
import { API } from \\"aws-amplify\\";
import { listPrimaryAuthors, listPrimaryTitles } from \\"../graphql/queries\\";
import { listAuthors, listTitles } from \\"../graphql/queries\\";
import { createBook } from \\"../graphql/mutations\\";
function ArrayField({
items = [],
Expand Down Expand Up @@ -3290,7 +3290,7 @@ export default function BookCreateForm(props) {
}
const result = (
await API.graphql({
query: listPrimaryAuthors,
query: listAuthors,
variables,
})
).data.listPrimaryAuthors.item;
Expand All @@ -3317,7 +3317,7 @@ export default function BookCreateForm(props) {
}
const result = (
await API.graphql({
query: listPrimaryTitles,
query: listTitles,
variables,
})
).data.listPrimaryTitles.item;
Expand Down Expand Up @@ -5184,7 +5184,7 @@ import {
import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\";
import { fetchByPath, validateField } from \\"./utils\\";
import { API } from \\"aws-amplify\\";
import { getComment, listPostIDS, listPosts } from \\"../graphql/queries\\";
import { getComment, listPosts } from \\"../graphql/queries\\";
import { updateComment } from \\"../graphql/mutations\\";
function ArrayField({
items = [],
Expand Down Expand Up @@ -5469,7 +5469,7 @@ export default function CommentUpdateForm(props) {
}
const result = (
await API.graphql({
query: listPostIDS,
query: listPosts,
variables,
})
).data.listPostIDS.item;
Expand Down Expand Up @@ -7513,10 +7513,7 @@ import {
import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\";
import { fetchByPath, validateField } from \\"./utils\\";
import { API } from \\"aws-amplify\\";
import {
listCompositeDogCompositeToysDescriptions,
listCompositeDogCompositeToysNames,
} from \\"../graphql/queries\\";
import { listCompositeDogs } from \\"../graphql/queries\\";
import { createCompositeToy } from \\"../graphql/mutations\\";
function ArrayField({
items = [],
Expand Down Expand Up @@ -7793,7 +7790,7 @@ export default function CreateCompositeToyForm(props) {
}
const result = (
await API.graphql({
query: listCompositeDogCompositeToysNames,
query: listCompositeDogs,
variables,
})
).data.listCompositeDogCompositeToysNames.item;
Expand Down Expand Up @@ -7825,7 +7822,7 @@ export default function CreateCompositeToyForm(props) {
}
const result = (
await API.graphql({
query: listCompositeDogCompositeToysDescriptions,
query: listCompositeDogs,
variables,
})
).data.listCompositeDogCompositeToysDescriptions.item;
Expand Down Expand Up @@ -8247,12 +8244,7 @@ import {
import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\";
import { fetchByPath, validateField } from \\"./utils\\";
import { API } from \\"aws-amplify\\";
import {
listOrgs,
listPostCommentsIds,
listPosts,
listUsers,
} from \\"../graphql/queries\\";
import { listOrgs, listPosts, listUsers } from \\"../graphql/queries\\";
import { createComment } from \\"../graphql/mutations\\";
function ArrayField({
items = [],
Expand Down Expand Up @@ -8636,7 +8628,7 @@ export default function CreateCommentForm(props) {
}
const result = (
await API.graphql({
query: listPostCommentsIds,
query: listPosts,
variables,
})
).data.listPostCommentsIds.item;
Expand Down
2 changes: 1 addition & 1 deletion packages/codegen-ui-react/lib/utils/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export const getFetchRelatedRecordsCallbacks = (
wrapInParenthesizedExpression(
getGraphqlCallExpression(
ActionType.LIST,
capitalizeFirstLetter(renderedFieldName),
relationship.relatedModelName,
importCollection,
[
factory.createShorthandPropertyAssignment(
Expand Down
2 changes: 1 addition & 1 deletion packages/test-generator/lib/models/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ export default {
isArrayNullable: true,
association: {
connectionType: 'HAS_MANY',
associatedWith: ['dealership'],
associatedWith: ['dealershipId'],
},
},
createdAt: {
Expand Down
1 change: 1 addition & 0 deletions scripts/integ-templates.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

lerna run build --scope @aws-amplify/codegen-ui-test-generator
cp -r packages/test-generator/integration-test-templates/. packages/integration-test
Expand Down