detrohutt/babel-plugin-import-graphql

Syntax Error: Unexpected <EOF>

farzd opened this issue ยท 6 comments

farzd commented

Hey,
I seem to get getting this error. I'm using react native, expo to be specific.
I know it works with expo because this guy seems to be using it
https://github.com/fabien0102/climbing-app

image

I dont think i'm doing anything wrong, just importing the .graphql file.

query userProfiles($userId: String!) {
  user(id: $userId) {
    id
    name
    image
}

when i import it in my component, i get the error.

import userProfiles from '../queries/userProfiles.graphql'```

Goes away when i remove the import

babel.rc

{
  "presets": ["babel-preset-expo"],
  "plugins": ["babel-plugin-inline-import-graphql-ast"],
  "env": {
    "development": {
      "plugins": ["transform-react-jsx-source"]
    }
  }
}

@farzd Hi, thanks for letting me know about this. Are you using Mac OS to develop this? Also, can you let me know the versions of my package and any babel packages you are using?

farzd commented

Thanks for the response, 2.1.2

{
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "dependencies": {
    "babel-plugin-inline-import-graphql-ast": "^2.1.2",
    "expo": "^25.0.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
  },
  "devDependencies": {
    "eslint": "^4.14.0",
    "eslint-config-expo": "^6.0.0",
    "prettier": "^1.9.2"
  },
  "eslintConfig": {
    "extends": "expo"
  }
}

the babel version that expo/reactnative uses seems to be

"babel-core@6.26.0"

Hmm. Everything looks fine to me. You could've made my package a devDependency (unless that's a react-native/expo thing) but it won't cause any problems for it to be a regular dependency. I haven't used react-native before but I can try to throw together a reproduction in the next few days. I can look into it sooner if you can make the reproduction. What OS are you using?

Also, you may want to attempt using the beta version of my package instead. I made a change to the line-ending regex in that so maybe it would work better? babel-plugin-inline-import-graphql-ast@2.2.0-beta.1

farzd commented

Hey, thanks a million. Appreciate it
It didn't work unfortunately. I'm on OSX [El Capitan]

error is different though
Syntax Error: Expected name, found <EOF>

EDIT: i just restarted expo and simulator and it seems to work ๐Ÿ‘

Great! I'll close this for now, but if you run into any more problems let me know.