From e4f765b156ef6f64e8d80ee30fda2efb2c6e2ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kop=C5=99iva?= Date: Mon, 1 Jun 2026 22:56:16 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs(graphql-codegen-client-pres?= =?UTF-8?q?et):=20monorepo=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - callout that Next.js uses the Turbopack workspace root (lockfile directory) as the SWC cwd, not the Next app directory - add a Turborepo example using a workspace-root-relative artifactDirectory ("apps/web/src/gql") so monorepo users get a copy-pasteable config Co-Authored-By: Claude Opus 4.7 --- contrib/graphql-codegen-client-preset/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/contrib/graphql-codegen-client-preset/README.md b/contrib/graphql-codegen-client-preset/README.md index 6ad8e7c78..acbfbb73f 100644 --- a/contrib/graphql-codegen-client-preset/README.md +++ b/contrib/graphql-codegen-client-preset/README.md @@ -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 = { + experimental: { + swcPlugins: [ + [ + "@swc-contrib/plugin-graphql-codegen-client-preset", + { artifactDirectory: "apps/web/src/gql", gqlTagName: "graphql" }, + ], + ], + }, +}; +``` + #### `.swcrc` ```json5