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

docs: fix expanding of custom relations in customer and product category routes #10620

Merged
merged 1 commit into from
Dec 16, 2024
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
62 changes: 31 additions & 31 deletions www/apps/api-reference/specs/admin/openapi.full.yaml

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions www/apps/api-reference/specs/admin/paths/admin_customers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ get:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -21,7 +22,8 @@ get:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
- name: offset
Expand Down Expand Up @@ -4221,7 +4223,8 @@ post:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -4230,7 +4233,8 @@ post:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ get:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -27,7 +28,8 @@ get:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down Expand Up @@ -78,7 +80,8 @@ post:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -87,7 +90,8 @@ post:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ get:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -27,7 +28,8 @@ get:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
- name: offset
Expand Down Expand Up @@ -249,7 +251,8 @@ post:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -258,7 +261,8 @@ post:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ get:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -33,7 +34,8 @@ get:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down Expand Up @@ -92,7 +94,8 @@ post:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -101,7 +104,8 @@ post:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down Expand Up @@ -250,7 +254,8 @@ delete:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -259,7 +264,8 @@ delete:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ post:
- name: fields
in: query
description: >-
Comma-separated fields that should be included in the returned data.
"Comma-separated fields that should be included in the returned data.

if a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields.

without prefix it will replace the entire default fields.
without prefix it will replace the entire default fields. NOTE: This
route doesn't allow expanding custom relations."
required: false
schema:
type: string
Expand All @@ -27,7 +28,8 @@ post:
Comma-separated fields that should be included in the returned data.
If a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. Without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ get:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -22,7 +23,8 @@ get:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
- name: offset
Expand Down Expand Up @@ -677,7 +679,8 @@ post:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -686,7 +689,8 @@ post:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ get:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -27,7 +28,8 @@ get:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
- name: include_ancestors_tree
Expand Down Expand Up @@ -118,7 +120,8 @@ post:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -127,7 +130,8 @@ post:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ post:
Comma-separated fields that should be included in the returned data. if
a field is prefixed with `+` it will be added to the default fields,
using `-` will remove it from the default fields. without prefix it will
replace the entire default fields.
replace the entire default fields. NOTE: This route doesn't allow
expanding custom relations.
required: false
schema:
type: string
Expand All @@ -26,7 +27,8 @@ post:
Comma-separated fields that should be included in the returned data.
if a field is prefixed with `+` it will be added to the default
fields, using `-` will remove it from the default fields. without
prefix it will replace the entire default fields.
prefix it will replace the entire default fields. NOTE: This route
doesn't allow expanding custom relations.
externalDocs:
url: '#select-fields-and-relations'
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,43 +329,7 @@ The request will return the customer's details. You'll learn how to retrieve the

When you extend an existing data model through links, you also want to retrieve the custom properties with the data model.

### Retrieve in API Routes

To retrieve the `custom_name` property when you're retrieving the customer through API routes, such as the [Get Customer API Route](!api!/admin#customers_getcustomersid), pass in the `fields` query parameter `+custom.*`, which retrieves the linked `Custom` record's details.

<Note title="Tip">

The `+` prefix in `+custom.*` indicates that the relation should be retrieved with the default customer fields. Learn more about selecting fields and relations in the [API reference](!api!/admin#select-fields-and-relations).

</Note>

For example:

```bash
curl 'localhost:9000/admin/customers/{customer_id}?fields=+custom.*' \
-H 'Authorization: Bearer {token}'
```

Make sure to replace `{customer_id}` with the customer's ID, and `{token}` with an admin user's JWT token.

Among the returned `customer` object, you'll find a `custom` property which holds the details of the linked `Custom` record:

```json
{
"customer": {
// ...
"custom": {
"id": "01J9NP7ANXDZ0EAYF0956ZE1ZA",
"custom_name": "test",
"created_at": "2024-10-08T09:09:06.877Z",
"updated_at": "2024-10-08T09:09:06.877Z",
"deleted_at": null
}
}
}
```

### Retrieve using Query
### Retrieve in API Routes using Query

You can also retrieve the `Custom` record linked to a customer in your code using [Query](!docs!/learn/fundamentals/module-links/query).

Expand All @@ -381,6 +345,8 @@ const { data: [customer] } = await query.graph({
})
```

You can use Query in a custom route to retrieve the customer with its linked `Custom` record.

Learn more about how to use Query in [this guide](!docs!/learn/fundamentals/module-links/query).

---
Expand Down
2 changes: 1 addition & 1 deletion www/apps/resources/generated/edit-dates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ export const generatedEditDates = {
"app/commerce-modules/api-key/links-to-other-modules/page.mdx": "2024-10-08T08:05:36.596Z",
"app/commerce-modules/cart/extend/page.mdx": "2024-12-11T09:05:37.041Z",
"app/commerce-modules/cart/links-to-other-modules/page.mdx": "2024-10-08T08:22:35.190Z",
"app/commerce-modules/customer/extend/page.mdx": "2024-12-11T09:05:35.368Z",
"app/commerce-modules/customer/extend/page.mdx": "2024-12-16T14:11:47.517Z",
"app/commerce-modules/fulfillment/links-to-other-modules/page.mdx": "2024-10-08T14:58:24.935Z",
"app/commerce-modules/inventory/links-to-other-modules/page.mdx": "2024-10-08T15:18:30.109Z",
"app/commerce-modules/pricing/links-to-other-modules/page.mdx": "2024-10-09T13:51:49.986Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* type: string
* - name: fields
* in: query
* description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
* fields. without prefix it will replace the entire default fields.
* description: "Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
* fields. without prefix it will replace the entire default fields. NOTE: This route doesn't allow expanding custom relations."
* required: false
* schema:
* type: string
* title: fields
* description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
* fields. without prefix it will replace the entire default fields.
* description: "Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
* fields. without prefix it will replace the entire default fields. NOTE: This route doesn't allow expanding custom relations."
* externalDocs:
* url: "#select-fields-and-relations"
* security:
Expand Down
Loading
Loading