diff --git a/src/pages/[platform]/build-a-backend/data/query-data/index.mdx b/src/pages/[platform]/build-a-backend/data/query-data/index.mdx
index 0b1402143aa..510c1f2f72c 100644
--- a/src/pages/[platform]/build-a-backend/data/query-data/index.mdx
+++ b/src/pages/[platform]/build-a-backend/data/query-data/index.mdx
@@ -147,6 +147,8 @@ const {
});
```
+
+
If you're building a React application, you can use the `usePagination` hook in Amplify UI to help with managing the pagination user experience.
```js
@@ -187,6 +189,8 @@ export const PaginationHasMorePagesExample = () => {
};
```
+
+
**Limitations:**
@@ -214,7 +218,11 @@ const { data: blogWithSubsetOfData, errors } = await client.models.Blog.get(
## TypeScript type helpers for Amplify Data
-When using TypeScript, you frequently need to specify data model types for type generics. For instance, with React's `useState`, you provide a type in TypeScript to ensure type-safety in your component code using the state. Use the `Schema["MODEL_NAME"]["type"]` pattern to get TypeScript types for the shapes of data models returned from the backend API. This allows you to get consumable TypeScript types for the shapes of the data model return values coming from the backend API.
+When using TypeScript, you frequently need to specify data model types for type generics.
+
+
+
+For instance, with React's `useState`, you provide a type in TypeScript to ensure type-safety in your component code using the state. Use the `Schema["MODEL_NAME"]["type"]` pattern to get TypeScript types for the shapes of data models returned from the backend API. This allows you to get consumable TypeScript types for the shapes of the data model return values coming from the backend API.
```ts
import { type Schema } from '@/amplify/data/resource';
@@ -224,8 +232,21 @@ type Post = Schema['Post']['type'];
const [posts, setPosts] = useState([]);
```
+
+
+
+
+```ts
+import { type Schema } from '@/amplify/data/resource';
+
+type Post = Schema['Post']['type'];
+```
+
+
+
You can combine the `Schema["MODEL_NAME"]["type"]` type with the `SelectionSet` helper type to describe the return type of API requests using the `selectionSet` parameter:
+
```ts
import type { SelectionSet } from 'aws-amplify/data';
import type { Schema } from '../amplify/data/resource';
@@ -245,6 +266,88 @@ const fetchPosts = async () => {
}
```
+
+
+
+```ts
+
+
+
+
+
+
+
+```
+
+
+
+```ts
+import { Component, OnInit } from '@angular/core';
+import { generateClient, type SelectionSet } from 'aws-amplify/data';
+import type { Schema } from '../../../amplify/data/resource';
+import { CommonModule } from '@angular/common';
+
+const client = generateClient();
+
+const selectionSet = ['content', 'blog.author.*', 'comments.*'] as const;
+
+type PostWithComments = SelectionSet<
+ Schema['Post']['type'],
+ typeof selectionSet
+>;
+
+@Component({
+ selector: 'app-todos',
+ standalone: true,
+ imports: [CommonModule],
+ templateUrl: './todos.component.html',
+ styleUrls: ['./todos.component.css'],
+})
+export class TodosComponent implements OnInit {
+ posts: PostWithComments[] = [];
+
+ constructor() {}
+
+ ngOnInit(): void {
+ this.fetchPosts();
+ }
+
+ async fetchPosts(): Promise {
+ const { data: postsWithComments } = await client.models.Post.list({
+ selectionSet,
+ });
+ this.posts = postsWithComments;
+ }
+}
+```
+
+
## Cancel read requests
You can cancel any query API request by calling `.cancel` on the query request promise that's returned by `.list(...)` or `.get(...)`.