Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import with TypeScript aliases gives error #70

Open
vitalyiegorov opened this issue Nov 19, 2019 · 4 comments
Open

Import with TypeScript aliases gives error #70

vitalyiegorov opened this issue Nov 19, 2019 · 4 comments

Comments

@vitalyiegorov
Copy link

vitalyiegorov commented Nov 19, 2019

Our project uses TS alias imports and we get the following error:
import Query from '@shared/file.graphql';
Error: Cannot find module '@shared/file.graphql'

Only relative imports work:
import Query from '../file.graphql';

@buesing
Copy link

buesing commented Dec 19, 2019

Same here, but with using webpack aliases.

@LP1994
Copy link

LP1994 commented Jun 12, 2020

Yes:
image
image

No:
image

PS:
"gQLDir" is webpack aliases.
image

eError:
image

@LP1994
Copy link

LP1994 commented Jun 13, 2020

When using dynamic import, modifying ". Graphql" will trigger recompilation! But static import will not!

SO!!!
Recommended:
import('gQLDir/GraphQLDemo.graphql');
OR
import('../../../graphQL/GraphQLDemo.graphql');

With the dynamic import I mentioned above, there is no need to use script commands to delete the cache.

@LP1994
Copy link

LP1994 commented Jun 13, 2020

Alias cannot be used with "babel-plugin-import-graphql".
But!!!
Only "graphql-tag/loader","babel-plugin-import-graphql" are not used, but aliases can be used.
{
test: /.(graphql|gql)$/i,
use: [
{
loader: 'graphql-tag/loader',
},
],
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants