Skip to content

Commit

Permalink
fix: move graphql collection 'items' property access off of result va…
Browse files Browse the repository at this point in the history
…riable
  • Loading branch information
Justin Shih authored and awinberg-aws committed Sep 5, 2023
1 parent 2abdc77 commit 143ec64
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,8 @@ export default function AuthorProfileCollection(
query: listAuthors,
variables,
})
).data.listAuthors.items;
newCache.push(...result);
).data.listAuthors;
newCache.push(...result.items);
newNext = result.nextToken;
}
const cacheSlice = newCache.slice((page - 1) * pageSize, page * pageSize);
Expand Down Expand Up @@ -1121,8 +1121,8 @@ export default function CollectionOfCustomButtons(
query: listUsers,
variables,
})
).data.listUsers.items;
newCache.push(...result);
).data.listUsers;
newCache.push(...result.items);
newNext = result.nextToken;
}
const cacheSlice = newCache.slice((page - 1) * pageSize, page * pageSize);
Expand Down Expand Up @@ -1287,8 +1287,8 @@ export default function ListingCardCollection(
query: listUntitledModels,
variables,
})
).data.listUntitledModels.items;
newCache.push(...result);
).data.listUntitledModels;
newCache.push(...result.items);
newNext = result.nextToken;
}
const cacheSlice = newCache.slice((page - 1) * pageSize, page * pageSize);
Expand Down Expand Up @@ -1552,8 +1552,8 @@ export default function AuthorProfileCollection(
query: listAuthors,
variables,
})
).data.listAuthors.items;
newCache.push(...result);
).data.listAuthors;
newCache.push(...result.items);
newNext = result.nextToken;
}
const cacheSlice = newCache.slice((page - 1) * pageSize, page * pageSize);
Expand Down
60 changes: 32 additions & 28 deletions packages/codegen-ui-react/lib/react-studio-template-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2068,38 +2068,35 @@ export abstract class ReactStudioTemplateRenderer extends StudioTemplateRenderer
undefined,
factory.createPropertyAccessExpression(
factory.createPropertyAccessExpression(
factory.createPropertyAccessExpression(
factory.createParenthesizedExpression(
factory.createAwaitExpression(
factory.createCallExpression(
factory.createPropertyAccessExpression(
factory.createIdentifier('API'),
factory.createIdentifier('graphql'),
),
undefined,
[
factory.createObjectLiteralExpression(
[
factory.createPropertyAssignment(
factory.createIdentifier('query'),
factory.createIdentifier(modelQuery),
),
factory.createShorthandPropertyAssignment(
factory.createIdentifier('variables'),
undefined,
),
],
true,
),
],
factory.createParenthesizedExpression(
factory.createAwaitExpression(
factory.createCallExpression(
factory.createPropertyAccessExpression(
factory.createIdentifier('API'),
factory.createIdentifier('graphql'),
),
undefined,
[
factory.createObjectLiteralExpression(
[
factory.createPropertyAssignment(
factory.createIdentifier('query'),
factory.createIdentifier(modelQuery),
),
factory.createShorthandPropertyAssignment(
factory.createIdentifier('variables'),
undefined,
),
],
true,
),
],
),
),
factory.createIdentifier('data'),
),
factory.createIdentifier(modelQuery),
factory.createIdentifier('data'),
),
factory.createIdentifier('items'),
factory.createIdentifier(modelQuery),
),
),
],
Expand All @@ -2113,7 +2110,14 @@ export abstract class ReactStudioTemplateRenderer extends StudioTemplateRenderer
factory.createIdentifier('push'),
),
undefined,
[factory.createSpreadElement(factory.createIdentifier('result'))],
[
factory.createSpreadElement(
factory.createPropertyAccessExpression(
factory.createIdentifier('result'),
factory.createIdentifier('items'),
),
),
],
),
),
factory.createExpressionStatement(
Expand Down

0 comments on commit 143ec64

Please sign in to comment.