dotansimha / dotansimha/graphql-code-generator-community

Empty gql.ts with Vue <script lang="tsx" setup>

Open
#60 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

### Which packages are impacted by your issue?

_No response_

### Describe the bug

Hello there.
Thanks for your work, I really love this package!.

Recently Vue added support to TSX inside *.vue with setup components.

Unfortunately codegen does not work with it.
Here is the [stackblitz repro](https://stackblitz.com/edit/github-jnyub3?file=App.vue).

```vue

import {graphql} from './gql';

// This TSX code will broke codegen.
// Comment to make it work again.
// Anyway we can rewrite the component without `setup` and it will not work.
const Icon = () => <div>123</div>;

const query = graphql(/* GraphQL */`
query user {
user(id: 1) {
id
username
email
}
}
`);

```

### Your Example Website or App

https://stackblitz.com/edit/github-jnyub3?file=App.vue

### Steps to Reproduce the Bug or Issue

1. Run it -> `Unterminated regular expression. (11:29)`.
2. Comment 6th line -> works again.

### Expected behavior

It should compile well.
Locally it fails sillently and gql.ts file has empty documents.

### Screenshots or Videos

_No response_

### Platform

- OS: Mac, Linux
- NodeJS: 16.14.0
- `graphql` version: 16.6.0
- `@graphql-codegen/*` version(s): latest

### Codegen Config File

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

const config: CodegenConfig = {
schema: 'schema.graphql',
documents: ['document.graphql', 'App.vue'],
generates: {
'types.ts': { plugins: ['typescript', 'typescript-operations'] },
'./gql/': {
preset: 'client',
config: {
useTypeImports: true,
},
plugins: [],
},
},
};

export default config;
```

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.