docs: fix locale option passed to query (#14472)
This commit is contained in:
1 parent
893da93feb
commit
76ff8dcca8
7 files changed
+119
-101
No files matched your search
@@ -190,7 +190,7 @@ In your custom API routes, you can retrieve the request's locale from the `local
|
||||
For example, to retrieve blog posts with translated titles in the `/store/posts` API route:
|
||||
|
||||
export const apiRouteHighlights = [
|
||||
["13", "locale", "Pass the request locale to the query options."],
|
||||
["15", "locale", "Pass the request locale to the query options."],
|
||||
]
|
||||
|
||||
```ts title="src/api/routes/store/posts.ts" highlights={apiRouteHighlights}
|
||||
@@ -202,13 +202,15 @@ export async function GET(
|
||||
) {
|
||||
const query = req.scope.resolve("query")
|
||||
|
||||
const { data: posts } = await query.graph({
|
||||
entity: "post",
|
||||
fields: ["id", "title"],
|
||||
options: {
|
||||
locale: req.locale,
|
||||
const { data: posts } = await query.graph(
|
||||
{
|
||||
entity: "post",
|
||||
fields: ["id", "title"],
|
||||
},
|
||||
})
|
||||
{
|
||||
locale: req.locale,
|
||||
}
|
||||
)
|
||||
|
||||
res.json({ posts })
|
||||
}
|
||||
@@ -324,4 +326,4 @@ The returned posts in the API response will have their `title` field set to the
|
||||
|
||||
For more complex cases, you can manage translations for your custom data models programmatically using the Translation Module's service. You can create, update, delete, and retrieve translations of any resource using the service's methods.
|
||||
|
||||
Refer to the [Translation Module service reference](/references/translation) for a full list of available methods and how to use them.
|
||||
Refer to the [Translation Module service reference](/references/translation) for a full list of available methods and how to use them.
|
||||
@@ -6937,5 +6937,5 @@ export const generatedEditDates = {
|
||||
"app/how-to-tutorials/how-to/admin/auth/page.mdx": "2025-12-30T06:35:28.828Z",
|
||||
"app/integrations/guides/okta/page.mdx": "2025-12-30T06:35:28.653Z",
|
||||
"app/nextjs-starter/guides/remove-country-code/page.mdx": "2025-12-30T10:28:10.072Z",
|
||||
"app/commerce-modules/translation/custom-data-models/page.mdx": "2026-01-06T08:49:12.704Z"
|
||||
"app/commerce-modules/translation/custom-data-models/page.mdx": "2026-01-06T15:54:25.801Z"
|
||||
}
|
||||
Reference in new issue
Block a user