ardatan/graphql-import

Unable to find any GraphQL type definitions

dkvilo opened this issue · 5 comments

if you are using babel-node or babel CLI to build the source and you have the following folder structure error occurs

  • src
    • graphql/:
      • schema.graphql
      • user.graphql
    • resolvers/
    • controllers/
    • index.js
  • package.json
    ...

log

Works fine for following

  • graphql/:
    • schema.graphql
    • user.graphql
  • resolvers/
  • controllers/
  • package.json
  • index.js
    ...
JexPY commented

Any updates?

I was able to get around this by using an absolute path with path.join(__dirname, 'schema.graphql'). My directory doesn't look exactly like yours but hopefully switching to absolute path fixes problem for now

I was able to get around this by using an absolute path with path.join(__dirname, 'schema.graphql'). My directory doesn't look exactly like yours but hopefully switching to absolute path fixes problem for now

Hello,
Yes, I tried this approach before submitting the issue but wasn't working with my dir structure. finally, I end up with coping the .graphql files to the dist folder.

"build": "babel src -d vendor && ncp src/graphql/schema.graphql vendor/graphql/schema.graphql"

@ChrisFieldsII's solution worked well here. Thks!

When you run graphql-import from your dist/ directory, it throws that error because you don't have those graphql files in your dist/ directory.
What you need to do is to move graphql files as suggested above.