docs: add new troubleshooting guides for Query and middlewares (#12214)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
A common mistake when creating middlewares is naming the file `middleware.ts` rather than `middlewares.ts`.
|
||||
|
||||
If your middleware isn't registered correctly, make sure you've created the middleware file at `src/api/middlewares.ts`.
|
||||
|
||||
Learn more in the [Middleware](!docs!/learn/fundamentals/api-routes/middlewares) documentation.
|
||||
@@ -0,0 +1,41 @@
|
||||
import { CodeTab, CodeTabs } from "docs-ui"
|
||||
|
||||
If you get the following error while using `query.graph` or `useQueryGraphStep`:
|
||||
|
||||
```bash
|
||||
Expression produces a union type that is too complex to represent. ts(2590)
|
||||
```
|
||||
|
||||
## Why this Error Occurred
|
||||
|
||||
This type error may occur when you use Query, but it's only a type error that doesn't affect the functionality of your code. It occurs because the models you're retrieving may be too complicated for the TypeScript compiler to infer the types correctly.
|
||||
|
||||
---
|
||||
|
||||
## How to Fix it
|
||||
|
||||
You can ignore this error by using the `// @ts-ignore` directive before the line of code that produces the error. For example:
|
||||
|
||||
<CodeTabs group="query">
|
||||
<CodeTab label="query.graph" value="query.graph">
|
||||
|
||||
```ts
|
||||
// @ts-ignore
|
||||
const { data } = await query.graph({
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="useQueryGraphStep" value="useQueryGraphStep">
|
||||
|
||||
```ts
|
||||
// @ts-ignore
|
||||
const { data } = useQueryGraphStep({
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
|
||||
</CodeTabs>
|
||||
@@ -1,4 +1,4 @@
|
||||
import AdditionalDataError from "../_sections/api-routes/additional-data.mdx"
|
||||
import AdditionalDataError from "../../_sections/api-routes/additional-data.mdx"
|
||||
|
||||
export const metadata = {
|
||||
title: `Unrecognized fields \`additiona_data\` Error`,
|
||||
@@ -0,0 +1,13 @@
|
||||
import MiddlewareFileName from "../../_sections/api-routes/middleware-file-name.mdx"
|
||||
|
||||
export const metadata = {
|
||||
title: `Middleware Registration Troubleshooting`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
This troubleshooting guide will help you debug why your middleware is not being registered correctly.
|
||||
|
||||
## Incorrect Middleware File Name
|
||||
|
||||
<MiddlewareFileName />
|
||||
@@ -0,0 +1,9 @@
|
||||
import ExpressionTypeError from "../../_sections/query/expression-type-error.mdx"
|
||||
|
||||
export const metadata = {
|
||||
title: `Error: Expression produces a union type that is too complex to represent`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
<ExpressionTypeError />
|
||||
Reference in New Issue
Block a user