Skip to content

Commit dd7894f

Browse files
committed
fixes
1 parent d58b1f8 commit dd7894f

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

www/apps/book/app/learn/fundamentals/module-links/query/page.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const { data: posts } = await query.graph({
127127
})
128128
```
129129

130-
`.*` means that all of data model's properties should be retrieved. You can also retrieve specific properties by replacing the `*` with the property name, for each property.
130+
`.*` means that all of the data model's properties should be retrieved. You can also retrieve specific properties by replacing the `*` with the property name for each property.
131131

132132
For example:
133133

@@ -166,7 +166,7 @@ In the example above, you retrieve all products linked to a post.
166166

167167
### Apply Filters and Pagination on Linked Records
168168

169-
Consider you want to apply filters or pagination configurations on the product(s) linked to `post`. To do that, you must query the module link's table instead.
169+
Consider that you want to apply filters or pagination configurations on the product(s) linked to a `post`. To do that, you must query the module link's table instead.
170170

171171
As mentioned in the [Module Link](../page.mdx) documentation, Medusa creates a table for your module link. So, not only can you retrieve linked records, but you can also retrieve the records in a module link's table.
172172

@@ -199,7 +199,7 @@ const { data: productCustoms } = await query.graph({
199199
In the object passed to the `graph` method:
200200

201201
- You pass the `entryPoint` property of the link definition as the value for `entity`. So, Query will retrieve records from the module link's table.
202-
- You pass three items to the `field` property:
202+
- You pass three items to the `fields` property:
203203
- `*` to retrieve the link table's fields. This is useful if the link table has [custom columns](../custom-columns/page.mdx).
204204
- `product.*` to retrieve the fields of a product record linked to a `Post` record.
205205
- `post.*` to retrieve the fields of a `Post` record linked to a product record.
@@ -272,7 +272,7 @@ Under the hood, Query uses one of the following methods from the data model's mo
272272
- `listX` if you don't pass [pagination parameters](#apply-pagination). For example, `listPosts`.
273273
- `listAndCountX` if you pass pagination parameters. For example, `listAndCountPosts`.
274274

275-
Both methods accepts a filter object that can be used to filter records.
275+
Both methods accept a filter object that can be used to filter records.
276276

277277
Those filters don't just allow you to filter by exact values. You can also filter by properties that don't match a value, match multiple values, and other filter types.
278278

@@ -497,7 +497,7 @@ In the example above, you retrieve only deleted posts by enabling the `withDelet
497497

498498
## Configure Query to Throw Errors
499499

500-
By default, if Query doesn't find records matching your query, it returns an empty array. You can add option to configure Query to throw an error when no records are found.
500+
By default, if Query doesn't find records matching your query, it returns an empty array. You can add an option to configure Query to throw an error when no records are found.
501501

502502
The `query.graph` method accepts as a second parameter an object that can have a `throwIfKeyNotFound` property. Its value is a boolean indicating whether to throw an error if no record is found when filtering by IDs. By default, it's `false`.
503503

@@ -536,7 +536,7 @@ const { data: posts } = await query.graph({
536536
})
537537
```
538538

539-
In the example above, Query throws an error either if no post is found with the ID `post_123` or if its found but its author ID isn't `author_123`.
539+
In the example above, Query throws an error either if no post is found with the ID `post_123` or if it's found but its author ID isn't `author_123`.
540540

541541
In the above example, it's assumed that a post belongs to an author, so it has an `author_id` property. However, this also works in the opposite case, where an author has many posts.
542542

@@ -615,7 +615,7 @@ The `validateAndTransformQuery` accepts two parameters:
615615
4. `order`: The fields to order the returned items by in ascending or descending order.
616616
2. A Query configuration object. It accepts the following properties:
617617
1. `defaults`: An array of default fields and relations to retrieve in each resource.
618-
2. `isList`: A boolean indicating whether a list of items are returned in the response.
618+
2. `isList`: A boolean indicating whether a list of items is returned in the response.
619619
3. `allowed`: An array of fields and relations allowed to be passed in the `fields` query parameter.
620620
4. `defaultLimit`: A number indicating the default limit to use if no limit is provided. By default, it's `50`.
621621

@@ -631,7 +631,7 @@ As of [Medusa v2.2.0](https://github.com/medusajs/medusa/releases/tag/v2.2.0), `
631631

632632
</Note>
633633

634-
For example, Create the file `src/api/customs/route.ts` with the following content:
634+
For example, create the file `src/api/customs/route.ts` with the following content:
635635

636636
export const queryConfigHighlights = [
637637
["17", "req.queryConfig", "Pass the parsed request Query configurations to the Query graph execution."]
@@ -667,7 +667,7 @@ In the API route, you pass `req.queryConfig` to `query.graph`. `queryConfig` has
667667

668668
### Test it Out
669669

670-
To test it out, start your Medusa application and send a `GET` request to the `/customs` API route. A list of records are retrieved with the specified fields in the middleware.
670+
To test it out, start your Medusa application and send a `GET` request to the `/customs` API route. A list of records is retrieved with the specified fields in the middleware.
671671

672672
```json title="Returned Data"
673673
{
@@ -684,6 +684,6 @@ Try passing one of the Query configuration parameters, like `fields` or `limit`,
684684

685685
<Note>
686686

687-
Learn more about [specifing fields and relations](!api!/store#select-fields-and-relations) and [pagination](!api!/store#pagination) in the API reference.
687+
Learn more about [specifying fields and relations](!api!/store#select-fields-and-relations) and [pagination](!api!/store#pagination) in the API reference.
688688

689689
</Note>

www/apps/book/generated/edit-dates.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const generatedEditDates = {
6666
"app/learn/fundamentals/module-links/custom-columns/page.mdx": "2025-03-11T13:29:54.752Z",
6767
"app/learn/fundamentals/module-links/directions/page.mdx": "2025-03-17T12:52:06.161Z",
6868
"app/learn/fundamentals/module-links/page.mdx": "2025-04-17T08:50:17.036Z",
69-
"app/learn/fundamentals/module-links/query/page.mdx": "2025-06-26T15:22:09.672Z",
69+
"app/learn/fundamentals/module-links/query/page.mdx": "2025-06-26T15:24:54.686Z",
7070
"app/learn/fundamentals/modules/db-operations/page.mdx": "2025-04-25T14:26:25.000Z",
7171
"app/learn/fundamentals/modules/multiple-services/page.mdx": "2025-03-18T15:11:44.632Z",
7272
"app/learn/fundamentals/modules/page.mdx": "2025-03-18T07:51:09.049Z",

www/apps/book/public/llms-full.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12237,7 +12237,7 @@ const { data: posts } = await query.graph({
1223712237
})
1223812238
```
1223912239

12240-
`.*` means that all of data model's properties should be retrieved. You can also retrieve specific properties by replacing the `*` with the property name, for each property.
12240+
`.*` means that all of the data model's properties should be retrieved. You can also retrieve specific properties by replacing the `*` with the property name for each property.
1224112241

1224212242
For example:
1224312243

@@ -12276,7 +12276,7 @@ In the example above, you retrieve all products linked to a post.
1227612276

1227712277
### Apply Filters and Pagination on Linked Records
1227812278

12279-
Consider you want to apply filters or pagination configurations on the product(s) linked to `post`. To do that, you must query the module link's table instead.
12279+
Consider that you want to apply filters or pagination configurations on the product(s) linked to a `post`. To do that, you must query the module link's table instead.
1228012280

1228112281
As mentioned in the [Module Link](https://docs.medusajs.com/learn/fundamentals/module-links/index.html.md) documentation, Medusa creates a table for your module link. So, not only can you retrieve linked records, but you can also retrieve the records in a module link's table.
1228212282

@@ -12302,7 +12302,7 @@ const { data: productCustoms } = await query.graph({
1230212302
In the object passed to the `graph` method:
1230312303

1230412304
- You pass the `entryPoint` property of the link definition as the value for `entity`. So, Query will retrieve records from the module link's table.
12305-
- You pass three items to the `field` property:
12305+
- You pass three items to the `fields` property:
1230612306
- `*` to retrieve the link table's fields. This is useful if the link table has [custom columns](https://docs.medusajs.com/learn/fundamentals/module-links/custom-columns/index.html.md).
1230712307
- `product.*` to retrieve the fields of a product record linked to a `Post` record.
1230812308
- `post.*` to retrieve the fields of a `Post` record linked to a product record.
@@ -12371,7 +12371,7 @@ Under the hood, Query uses one of the following methods from the data model's mo
1237112371
- `listX` if you don't pass [pagination parameters](#apply-pagination). For example, `listPosts`.
1237212372
- `listAndCountX` if you pass pagination parameters. For example, `listAndCountPosts`.
1237312373

12374-
Both methods accepts a filter object that can be used to filter records.
12374+
Both methods accept a filter object that can be used to filter records.
1237512375

1237612376
Those filters don't just allow you to filter by exact values. You can also filter by properties that don't match a value, match multiple values, and other filter types.
1237712377

@@ -12565,7 +12565,7 @@ In the example above, you retrieve only deleted posts by enabling the `withDelet
1256512565

1256612566
## Configure Query to Throw Errors
1256712567

12568-
By default, if Query doesn't find records matching your query, it returns an empty array. You can add option to configure Query to throw an error when no records are found.
12568+
By default, if Query doesn't find records matching your query, it returns an empty array. You can add an option to configure Query to throw an error when no records are found.
1256912569

1257012570
The `query.graph` method accepts as a second parameter an object that can have a `throwIfKeyNotFound` property. Its value is a boolean indicating whether to throw an error if no record is found when filtering by IDs. By default, it's `false`.
1257112571

@@ -12604,7 +12604,7 @@ const { data: posts } = await query.graph({
1260412604
})
1260512605
```
1260612606

12607-
In the example above, Query throws an error either if no post is found with the ID `post_123` or if its found but its author ID isn't `author_123`.
12607+
In the example above, Query throws an error either if no post is found with the ID `post_123` or if it's found but its author ID isn't `author_123`.
1260812608

1260912609
In the above example, it's assumed that a post belongs to an author, so it has an `author_id` property. However, this also works in the opposite case, where an author has many posts.
1261012610

@@ -12683,7 +12683,7 @@ The `validateAndTransformQuery` accepts two parameters:
1268312683
4. `order`: The fields to order the returned items by in ascending or descending order.
1268412684
2. A Query configuration object. It accepts the following properties:
1268512685
1. `defaults`: An array of default fields and relations to retrieve in each resource.
12686-
2. `isList`: A boolean indicating whether a list of items are returned in the response.
12686+
2. `isList`: A boolean indicating whether a list of items is returned in the response.
1268712687
3. `allowed`: An array of fields and relations allowed to be passed in the `fields` query parameter.
1268812688
4. `defaultLimit`: A number indicating the default limit to use if no limit is provided. By default, it's `50`.
1268912689

@@ -12695,7 +12695,7 @@ The middleware transforms these parameters to configurations that you can pass t
1269512695

1269612696
As of [Medusa v2.2.0](https://github.com/medusajs/medusa/releases/tag/v2.2.0), `remoteQueryConfig` has been deprecated in favor of `queryConfig`. Their usage is still the same, only the property name has changed.
1269712697

12698-
For example, Create the file `src/api/customs/route.ts` with the following content:
12698+
For example, create the file `src/api/customs/route.ts` with the following content:
1269912699

1270012700
```ts title="src/api/customs/route.ts"
1270112701
import {
@@ -12727,7 +12727,7 @@ In the API route, you pass `req.queryConfig` to `query.graph`. `queryConfig` has
1272712727

1272812728
### Test it Out
1272912729

12730-
To test it out, start your Medusa application and send a `GET` request to the `/customs` API route. A list of records are retrieved with the specified fields in the middleware.
12730+
To test it out, start your Medusa application and send a `GET` request to the `/customs` API route. A list of records is retrieved with the specified fields in the middleware.
1273112731

1273212732
```json title="Returned Data"
1273312733
{
@@ -12742,7 +12742,7 @@ To test it out, start your Medusa application and send a `GET` request to the `/
1274212742

1274312743
Try passing one of the Query configuration parameters, like `fields` or `limit`, and you'll see its impact on the returned result.
1274412744

12745-
Learn more about [specifing fields and relations](https://docs.medusajs.com/api/store#select-fields-and-relations) and [pagination](https://docs.medusajs.com/api/store#pagination) in the API reference.
12745+
Learn more about [specifying fields and relations](https://docs.medusajs.com/api/store#select-fields-and-relations) and [pagination](https://docs.medusajs.com/api/store#pagination) in the API reference.
1274612746

1274712747

1274812748
# Read-Only Module Link

0 commit comments

Comments
 (0)