Skip to content

Commit

Permalink
fix: use related model name instead of field in generating graphql qu… (
Browse files Browse the repository at this point in the history
#1039)

* fix: use related model name instead of field in generating graphql queries

* fix: updating invalid schema in integ test

* feat: exit early in integ test failure

* fix: lowering nyc coverage threshold
  • Loading branch information
bombguy authored and David Lopez committed Jul 19, 2023
1 parent befd567 commit eca9fef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
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 @@ -348,7 +348,7 @@ export const getFetchRelatedRecordsCallbacks = (
wrapInParenthesizedExpression(
getGraphqlCallExpression(
ActionType.LIST,
capitalizeFirstLetter(renderedFieldName),
relationship.relatedModelName,
importCollection,
[
factory.createShorthandPropertyAssignment(
Expand Down

0 comments on commit eca9fef

Please sign in to comment.