Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions website/src/pages/plugins/presets/preset-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -617,26 +617,10 @@ module.exports = {

### SWC Plugin

<Callout type="warning">
As of 2023/03/11, SWC's custom plugins is still an experimental feature, that means unexpected breaking changes that
makes specific nextjs versions or our plugin incompatible are possible, so please file an issue
[here](https://github.com/dotansimha/graphql-code-generator/issues/new?assignees=&labels=&template=bug_report.yml&title=@graphql-codegen/client-preset-swc-plugin%20...)
if you faced any unexpected behavior/errors while using the plugin.

Pro tip: if you faced the following obscure error, or the nextjs `dev` script just instantly terminates the process without any errors,
it most likely means that SWC is not happy with your nextjs version, so try upgrading it to `latest` if possible,
then let us know of your current broken version to try fixing it or documenting its no longer supported.

```sh
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/app/node_modules/next/dist/client/router.js")'
```

</Callout>

The SWC plugin is not bundled in the `client-preset` package, so you will need to install it separately:

```sh npm2yarn
npm i -D @graphql-codegen/client-preset-swc-plugin
npm i -D @swc-contrib/plugin-graphql-codegen-client-preset
```

#### General
Expand All @@ -650,7 +634,7 @@ To use the SWC plugin without Next.js, update your `.swcrc` to add the following
// ...
experimental: {
plugins: [
['@graphql-codegen/client-preset-swc-plugin', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
['@swc-contrib/plugin-graphql-codegen-client-preset', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
]
}
}
Expand All @@ -670,7 +654,7 @@ export default defineConfig({
plugins: [
react({
plugins: [
['@graphql-codegen/client-preset-swc-plugin', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
['@swc-contrib/plugin-graphql-codegen-client-preset', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
]
})
]
Expand All @@ -686,7 +670,7 @@ const nextConfig = {
// ...
experimental: {
swcPlugins: [
['@graphql-codegen/client-preset-swc-plugin', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
['@swc-contrib/plugin-graphql-codegen-client-preset', { artifactDirectory: './src/gql', gqlTagName: 'graphql' }]
]
}
}
Expand Down
Loading