Reputation: 5431
Trying to import this file:
subscription onNewNotification {
notification {
id
content
seen
}
}
I get this error when running babel-node to compile the whole thing: SyntaxError: .../graphql/NotificationSubscription.graphql: Unexpected token, expected ;
This is how my webpack loaders look like:
module: {
loaders: [
{
test: /\.js?$/,
include: [
path.join(__dirname, 'client'),
path.join(__dirname, 'server/shared'),
],
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react-hmre'],
},
},
{
test: /\.json?$/,
loader: 'json-loader',
},
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader'],
},
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?mimetype=image/svg+xml' },
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
],
},
No idea why this is happening, I'm following the Apollo docs and I don't see anything about this on google: http://dev.apollodata.com/react/webpack.html
Upvotes: 7
Views: 3489
Reputation: 309
Well, I am having the same problem too. After talk with on guy on apollo slack channel we start to debug and discover what is the problem. We discover that the problem was the 'babel-register' that in some kind of way trying to compile the .graphql
files even with the rule to ignore. So there are two paths you can go:
react-apollo
package and export it as a variable. Upvotes: 1