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
gql A JavaScript template literal tag that parses GraphQL query strings into the standard GraphQL AST. /loader A webpack loader to preprocess queries.
Being a globally unique identifier means that the URL is unique and cannot have duplicates. In GraphQL, the POST HTTP method is used to perform queries and there are no URL-like endpoints like we have in RESTful APIs. This makes caching GraphQL queries difficult.
makeExecutableSchema combines schema and resolvers to make executable schema. It's part of a graphql-tools package that makes it easier to use the schema language while also writing resolvers. So you define types and resolvers and pass them to makeExecutableSchema .
HTTP caches will not caches POST requests, which means GraphQL is simply not cacheable at the HTTP level. However, GET is indeed a valid way to query a GraphQL server over HTTP. This means that caches could indeed cache GraphQL responses.
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. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With