You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/react-scripts/template/README.md
+31-2
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
27
27
-[Post-Processing CSS](#post-processing-css)
28
28
-[Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc)
29
29
-[Adding Images, Fonts, and Files](#adding-images-fonts-and-files)
30
+
-[Adding GraphQL files](#adding-graphql-files)
30
31
-[Using the `public` Folder](#using-the-public-folder)
31
32
-[Changing the HTML](#changing-the-html)
32
33
-[Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system)
@@ -299,7 +300,7 @@ In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and s
299
300
300
301
Start your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm.
301
302
302
-
The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine.
303
+
The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine.
303
304
304
305
## Formatting Code Automatically
305
306
@@ -695,6 +696,34 @@ Please be advised that this is also a custom feature of Webpack.
695
696
**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).<br>
696
697
An alternative way of handling static assets is described in the next section.
697
698
699
+
## Adding GraphQL files
700
+
701
+
> Note: this feature is available with react-scripts@2.0.0 and higher.
702
+
703
+
If you are using GraphQL, you can **`import` GraphQL files in a JavaScript module**.
704
+
705
+
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.
706
+
707
+
Here is an example:
708
+
709
+
```js
710
+
// query.graphql
711
+
{
712
+
githubStats(repository:"facebook/react") {
713
+
stars
714
+
}
715
+
}
716
+
717
+
// foo.js
718
+
719
+
importqueryfrom'./query.graphql';
720
+
721
+
console.log(query);
722
+
// {
723
+
// "kind": "Document",
724
+
// ...
725
+
```
726
+
698
727
## Using the `public` Folder
699
728
700
729
>Note: this feature is available with `react-scripts@0.5.0` and higher.
@@ -2002,7 +2031,7 @@ If you’re using [Apache HTTP Server](https://httpd.apache.org/), you need to c
2002
2031
RewriteRule ^index.html [QSA,L]
2003
2032
```
2004
2033
2005
-
It will get copied to the `build` folder when you run `npm run build`.
2034
+
It will get copied to the `build` folder when you run `npm run build`.
2006
2035
2007
2036
If you’re using [Apache Tomcat](http://tomcat.apache.org/), you need to follow [this Stack Overflow answer](https://stackoverflow.com/a/41249464/4878474).
0 commit comments