Error configuring third-party wepack loaders with react-server

190 views Asked by At

I am wondering if I could get some help on an error i am receiving with react server. I am trying to use the graphql-tag/loader with react-server and I don’t know how to proceed from the current error. The current setup is this: in my .reactserverrc file i have this entry:

"webpackConfig": "./my.webpack.config.js"

That file has this:

 export default (webpackConfig) = { webpackConfig.module.loaders.unshift([
   {
      test: /\.(graphql|gql)$/,
      exclude: /node_modules/,
      loader: 'graphql-tag/loader'
    }
    ]);
    return webpackConfig
}

react server loads the config file fine and all looks good, but when trying to import a query, like so.

import userQuery from '../queries/query.graphql';

I get this error:

SyntaxError: <prefix_removed>/src/queries/user.graphql: Unexpected token, expected ; (1:6)
> 1 | query CurrentUserForLayout
    |       ^
  2 | {
  3 |   user {
  4 | 
    at Parser.pp$5.raise (/Users/zach/workspace/widget/dx/dx-ui-item/node_modules/babylon/lib/index.js:4333:13)
at Parser.pp.unexpected (/Users/zach/workspace/widget/dx/dx-ui-item/node_modules/babylon/lib/index.js:1705:8)
at Parser.pp.semicolon (/Users/zach/workspace/widget/dx/dx-ui-item/node_modules/babylon/lib/index.js:1686:38)
at Parser.pp$1.parseExpressionStatement (/Users/zach/workspace/widget/dx/dx-ui-item/node_modules/babylon/lib/index.js:2182:8)

It would appear that the loader is not being applied to the graphql file. Is there a way to debug this where I can see the loaders being applied to the files?

Any help is appreciated. Thanks,

Zach

0

There are 0 answers