-
-
Notifications
You must be signed in to change notification settings - Fork 102
📝 docs(graphql-codegen-client-preset): monorepo paths #627
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,22 @@ const nextConfig = { | |
| }; | ||
| ``` | ||
|
|
||
| > **Monorepos:** Next.js uses [Turbopack's workspace root](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#root-directory) — the directory containing your lockfile (`yarn.lock`, `pnpm-lock.yaml`, etc.) — as the SWC `cwd`. If your Next app lives below that root, write `artifactDirectory` as a path from the workspace root down to the codegen output, not as a path relative to the Next app: | ||
|
|
||
| ```ts | ||
| // apps/web/next.config.mjs, in a Turborepo where yarn.lock sits at the repo root | ||
| const nextConfig = { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because this added example is labeled Useful? React with 👍 / 👎. |
||
| experimental: { | ||
| swcPlugins: [ | ||
| [ | ||
| "@swc-contrib/plugin-graphql-codegen-client-preset", | ||
| { artifactDirectory: "apps/web/src/gql", gqlTagName: "graphql" }, | ||
| ], | ||
| ], | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| #### `.swcrc` | ||
|
|
||
| ```json5 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This callout is under the general Next.js section, but the behavior being linked is specifically Turbopack’s filesystem root and can also be changed with
turbopack.root. For a monorepo app still building with webpack, or one that pinsturbopack.rootto the app directory, following this advice makes the plugin joinapps/web/src/gqlonto the app cwd and resolveapps/web/apps/web/src/gql, reintroducing missing imports. Please qualify the guidance as applying only to Turbopack with the workspace-root cwd, or include the app-relative variant for other Next.js builds.Useful? React with 👍 / 👎.