-
Notifications
You must be signed in to change notification settings - Fork 56
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
ENOENT, when using # import syntax #284
Comments
@danielcooke1996 Did you found any solution? |
@didaquis I ended up just switching to https://github.com/detrohutt/babel-plugin-import-graphql |
Thanks |
Same issue here.
I switched to babel-plugin-import-graphql to have something working but I really want to use graphql-import |
Same issue here. I'm really looking forward to have this issue solved. Can't event put babel-plugin-import-graphql to work. |
When using It needs to be - Note there is no space between the hash and the import, and the filename has single quotes |
Having the same issue. Can't figure out why it worked before but not now though.. |
Make sure you give the correct path. For example: If your |
Maybe my repo could be an example for you: https://github.com/didaquis/react-graphql-apollo-example-server/tree/master/src/gql/schemas |
@jackgray, do you need a more practical example? |
As mentioned above, this will not work. As I have included a reproduction repo where you can see this behaviour. Note I have included full paths for my schema. |
Yeah this worked for me. Thank you |
You need to import the .graphql file from root even if your file is in the same folder: Let's say you've got this structure:
If you are trying to import user.graphql from index.js you will need to do this:
|
Hi @dan-cooke ! |
We have since switched to I don't really have much time to test this out for you, but you are welcome to clone the reproduction repo and determine for yourself! |
@dan-cooke I'm happy you are using |
Available in 1.0.0! |
Unless I am missing something crucial, I can't seem to get the # import syntax to work.
Reproduction
I have created the following repo to reproduce the bug
As you can see in that repo,
src/index.js
does the following:It imports
typeDefs/index.graphql
using theimport-graphql
babel plugin, this works as expected as the file is simply read as a string.It calls
importSchema
fromgraphql-import
. This is where the problem occurs.If you run that repo you will get the following error
The issue
Looking at the stack trace, the problem lies with how
graphql-import
is resolving the path. At index.js:26:19.The
read
function is not being passed the correct path when using relative paths. As you can see it is being passed the path _as is. i.e./store.graphql
and obviously this is not right, as the graphql file does not exist relative to the module, but relative to my source code.Other things I've tried
# import * from './store.graphql' from
typeDefs/index.graphql`, this works correctly, indicating that the issue is purely when resolving # import syntax.gql
filesimportSchema
directly, as opposed to a string.Environment
node: 11.9
graphql-import: 0.7.1
The text was updated successfully, but these errors were encountered: