Skip to content

Can't build app with @graphql-codegen/client-preset-swc-plugin #9195

@DaLukasDev

Description

@DaLukasDev

Which packages are impacted by your issue?

@graphql-codegen/client-preset-swc-plugin

Describe the bug

I'm using the Vite React implementation.
I was using the swc-plugin-graphql-codegen-client-preset-optimizer-test version without any problems but after updating some deps this one stopped working.

react({
     plugins: [
       [
         'swc-plugin-graphql-codegen-client-preset-optimizer-test',
         {
           artifactDirectory: '../../packages/data-access/src/gql',
         },
       ],
     ],
   }),

Same with the following config:

react({
      plugins: [
        [
          '@graphql-codegen/client-preset-swc-plugin',
          {
            artifactDirectory: '../../packages/data-access/src/gql',
          },
        ],
      ],
    }),

where react is an import as import react from '@vitejs/plugin-react-swc';

I always get the same error:

ERROR: The character ">" is not valid inside a JSX element
ERROR: Unexpected end of file before a closing "" tag

removing the plugin altogether fixes my issue.

Your Example Website or App

/

Steps to Reproduce the Bug or Issue

/

Expected behavior

Build should not fail

Screenshots or Videos

No response

Platform

  • OS: [Linux]
  • NodeJS: [e.g. 18.15.0]
  • graphql version: [e.g. ^16.6.0]
  • @graphql-codegen/* version(s): [e.g. 3.2.2 and client-preset 2.1.1]

Codegen Config File

import { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
  schema: '/app/apps/api/storage/app/lighthouse-schema.graphql',
  documents: ['src/**/*.tsx', '!src/gql/**/*'],
  verbose: true,
  generates: {
    './src/gql/': {
      preset: 'client',
      plugins: [],
      config: {
        skipTypename: false,
        enumsAsTypes: true,
      },
    },
  },
};

export default config;

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions