Skip to content

Commit 03a7091

Browse files
authored
Revert "Add loader for .graphql files (#3909)" (#5076)
1 parent 88a3de9 commit 03a7091

File tree

11 files changed

+1
-116
lines changed

11 files changed

+1
-116
lines changed

packages/react-scripts/config/jest/graphqlTransform.js

-18
This file was deleted.

packages/react-scripts/config/webpack.config.dev.js

-5
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,6 @@ module.exports = {
352352
'sass-loader'
353353
),
354354
},
355-
// The GraphQL loader preprocesses GraphQL queries in .graphql files.
356-
{
357-
test: /\.(graphql)$/,
358-
loader: 'graphql-tag/loader',
359-
},
360355
// "file" loader makes sure those assets get served by WebpackDevServer.
361356
// When you `import` an asset, you get its (virtual) filename.
362357
// In production, they would get copied to the `build` folder.

packages/react-scripts/config/webpack.config.prod.js

-5
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,6 @@ module.exports = {
391391
'sass-loader'
392392
),
393393
},
394-
// The GraphQL loader preprocesses GraphQL queries in .graphql files.
395-
{
396-
test: /\.(graphql)$/,
397-
loader: 'graphql-tag/loader',
398-
},
399394
// "file" loader makes sure assets end up in the `build` folder.
400395
// When you `import` an asset, you get its filename.
401396
// This loader doesn't use a "test" so it will catch all modules

packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js

-11
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,6 @@ describe('Integration', () => {
8181
doc.defaultView.close();
8282
});
8383

84-
it('graphql files inclusion', async () => {
85-
const doc = await initDOM('graphql-inclusion');
86-
const children = doc.getElementById('graphql-inclusion').children;
87-
88-
// .graphql
89-
expect(children[0].textContent.replace(/\s/g, '')).toBe(
90-
'{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}'
91-
);
92-
doc.defaultView.close();
93-
});
94-
9584
it('image inclusion', async () => {
9685
const doc = await initDOM('image-inclusion');
9786

packages/react-scripts/fixtures/kitchensink/src/App.js

-5
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ class App extends Component {
134134
this.setFeature(f.default)
135135
);
136136
break;
137-
case 'graphql-inclusion':
138-
import('./features/webpack/GraphQLInclusion').then(f =>
139-
this.setFeature(f.default)
140-
);
141-
break;
142137
case 'image-inclusion':
143138
import('./features/webpack/ImageInclusion').then(f =>
144139
this.setFeature(f.default)

packages/react-scripts/fixtures/kitchensink/src/features/webpack/GraphQLInclusion.js

-15
This file was deleted.

packages/react-scripts/fixtures/kitchensink/src/features/webpack/GraphQLInclusion.test.js

-17
This file was deleted.

packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/graphql.graphql

-5
This file was deleted.

packages/react-scripts/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
"eslint-plugin-react": "7.11.1",
4747
"file-loader": "1.1.11",
4848
"fs-extra": "7.0.0",
49-
"graphql": "0.13.2",
50-
"graphql-tag": "2.9.2",
5149
"html-webpack-plugin": "4.0.0-alpha.2",
5250
"identity-obj-proxy": "3.0.0",
5351
"jest": "23.6.0",

packages/react-scripts/scripts/utils/createJestConfig.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
3535
? '<rootDir>/node_modules/babel-jest'
3636
: resolve('config/jest/babelTransform.js'),
3737
'^.+\\.css$': resolve('config/jest/cssTransform.js'),
38-
'^.+\\.(graphql)$': resolve('config/jest/graphqlTransform.js'),
39-
'^(?!.*\\.(js|jsx|css|json|graphql)$)': resolve(
40-
'config/jest/fileTransform.js'
41-
),
38+
'^(?!.*\\.(js|jsx|css|json)$)': resolve('config/jest/fileTransform.js'),
4239
},
4340
transformIgnorePatterns: [
4441
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$',

packages/react-scripts/template/README.md

-29
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ You can find the most recent version of this guide [here](https://github.com/fac
2727
- [Post-Processing CSS](#post-processing-css)
2828
- [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc)
2929
- [Adding Images, Fonts, and Files](#adding-images-fonts-and-files)
30-
- [Adding GraphQL files](#adding-graphql-files)
3130
- [Using the `public` Folder](#using-the-public-folder)
3231
- [Changing the HTML](#changing-the-html)
3332
- [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system)
@@ -732,34 +731,6 @@ Please be advised that this is also a custom feature of Webpack.
732731
**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).<br>
733732
An alternative way of handling static assets is described in the next section.
734733

735-
## Adding GraphQL files
736-
737-
> Note: this feature is available with react-scripts@2.0.0 and higher.
738-
739-
If you are using GraphQL, you can **`import` GraphQL files in a JavaScript module**.
740-
741-
By importing GraphQL queries instead of using a [template tag](https://github.com/apollographql/graphql-tag), they are preprocessed at build time. This eliminates the need to process them on the client at run time. It also allows you to separate your GraphQL queries from your code. You can put a GraphQL query in a file with a `.graphql` extension.
742-
743-
Here is an example:
744-
745-
```js
746-
// query.graphql
747-
{
748-
githubStats(repository: "facebook/react") {
749-
stars
750-
}
751-
}
752-
753-
// foo.js
754-
755-
import query from './query.graphql';
756-
757-
console.log(query);
758-
// {
759-
// "kind": "Document",
760-
// ...
761-
```
762-
763734
## Using the `public` Folder
764735

765736
>Note: this feature is available with `react-scripts@0.5.0` and higher.

0 commit comments

Comments
 (0)