docs: fix locale option passed to query (#14472)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user