detrohutt / babel-plugin-import-graphql

Enables import syntax for .graphql and .gql files
https://www.npmjs.com/package/babel-plugin-import-graphql
MIT License
314 stars 22 forks source link

Plugin makes it impossible to import .gql.ts and .graphql.ts files #91

Open nielsmadan opened 2 years ago

nielsmadan commented 2 years ago

In order to import a file with .gql.ts extension, you would omit the .ts part in the import statement.

Since the plugin looks at importPath rather than the name of the actual file, it will handle it and import it as graphql, which will fail (assuming it is a ts file).

Attaching a patch that would fix it, but of course not sure if this has other implications.

babel-plugin-import-graphql+2.8.1.patch.txt

ronaldosc commented 6 months ago

@nielsmadan I couldn't realize the use of those files with GraphQL syntax but added .ts extension.

The original extension is important to retain. If you change it to TypeScript syntax you'll need a parser, but GraphQL has this parser natively or with a package.

A granulated code with the GraphQL code separated fits better and you separate codes from different syntax brings more readability for developing.

What you suggest more about?