graphql-playground-react compilation error in `node_modules`
This issue pertains to the following package(s):
- [ ] GraphQL Playground - Electron App
- [ ] GraphQL Playground HTML
- [X] GraphQL Playground
- [ ] GraphQL Playground Express Middleware
- [ ] GraphQL Playground Hapi Middleware
- [ ] GraphQL Playground Koa Middleware
- [ ] GraphQL Playground Lambda Middleware
What OS and OS version are you experiencing the issue(s) on?
MacOS 10.13.6
What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?
1.7.20
What is the expected behavior?
When rendering the React component from the As React component example, I expect the react components to render.
What is the actual behavior?
I see compilation errors about needing appropriate webpack loaders. Typically, packages ship with compiled versions of their projects so that there would not need to be a compile step for them. It is, however, likely that I'm doing something wrong.
Here is the output from my compilation:
ERROR in ./node_modules/graphql-playground-react/lib/components/GraphQLBinApp.jsx
Module parse failed: Unexpected token (109:16)
You may need an appropriate loader to handle this file type.
| subscriptionEndpoint = getParameterByName('subscription');
| }
| return (<Wrapper>
| {this.state.loading ? null : !this.state.endpoint ||
| this.state.endpoint.length === 0 ? (<styled_1.ThemeProvider theme={styled_1.theme}>
@ ./node_modules/graphql-playground-react/lib/lib.js 13:22-59
@ ./src/pages/graphql_playground/index.js
@ multi (webpack)-dev-server/client?https://localhost:8080 webpack/hot/dev-server ./src/pages/graphql_playground
ERROR in ./node_modules/graphql-playground-react/lib/components/Playground/GraphQLEditor.jsx
Module parse failed: Unexpected token (260:16)
You may need an appropriate loader to handle this file type.
| };
| GraphQLEditor.prototype.render = function () {
| return (<EditorWrapper_1.Container setRef={this.setContainerComponent}>
| <EditorWrapper_1.default>
| <TopBar_1.default shareEnabled={this.props.shareEnabled} fixedEndpoint={this.props.fixedEndpoint}/>
@ ./node_modules/graphql-playground-react/lib/lib.js 11:22-70
@ ./src/pages/graphql_playground/index.js
@ multi (webpack)-dev-server/client?https://localhost:8080 webpack/hot/dev-server ./src/pages/graphql_playground
ERROR in ./node_modules/graphql-playground-react/lib/components/PlaygroundWrapper.jsx
Module parse failed: Unexpected token (331:43)
You may need an appropriate loader to handle this file type.
| };
| PlaygroundWrapper.prototype.render = function () {
| var title = this.props.setTitle ? (<react_helmet_1.Helmet>
| <title>{this.getTitle()}</title>
| </react_helmet_1.Helmet>) : null;
@ ./node_modules/graphql-playground-react/lib/lib.js 9:26-67
@ ./src/pages/graphql_playground/index.js
@ multi (webpack)-dev-server/client?https://localhost:8080 webpack/hot/dev-server ./src/pages/graphql_playground
I managed to improve the situation a bit by making a change in my webpack config, by preferring js over jsx files:
resolve: {
- extensions: [".jsx", ".js", ".cjsx", ".coffee"],
+ extensions: [".js", ".jsx", ".cjsx", ".coffee"],
Now I get warnings about flow types (like in https://github.com/prisma/graphql-playground/issues/738), and a loader error about a png:
ERROR in ./node_modules/graphql-playground-react/lib/assets/logo.png
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
@ ./node_modules/graphql-playground-react/lib/components/EndpointPopup.js 92:58-87
@ ./node_modules/graphql-playground-react/lib/components/GraphQLBinApp.js
@ ./node_modules/graphql-playground-react/lib/lib.js
@ ./src/pages/graphql_playground/index.js
@ multi (webpack)-dev-server/client?https://localhost:8080 webpack/hot/dev-server ./src/pages/graphql_playground
I added file loader to my webpack config, and now it's compiling (still with flow errors). I'd love to see some information added to the readme about this, as it was totally unclear what I needed to do to actually get this running.
I have tried using this project a few times but gave up each time because of these same errors. I did manage to get the flow errors to go away by using ignore-loader like so:
{
test: /\.js.flow$/,
loader: 'ignore-loader'
}
Could you share your config setup? (Or at least the file-loader part that fixed these errors)
@michaelshiel I added the following to the rules section of my webpack config to ignore PNGs:
const modules = {
rules: [
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: "file-loader",
options: {},
},
],
},
// other rules go here
]
};
After adding the ignore-loader for Flow and the image-loader for images, the playground loads! It fetches my schema properly, but is now erroring out on something having to do with websockets:
This occurs when I try to execute a query.
Getting the same issue when using graphQl-playground-react with next.js.