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
You can load `.gql` and `.graphql` files by using [`babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros) included with Create React App.
8
+
9
+
To load the files, first install the [`graphl-tag.macro`](https://www.npmjs.com/package/graphql-tag.macro) package by running
10
+
11
+
```sh
12
+
npm install --save-dev graphl-tag.macro
13
+
```
14
+
15
+
Alternatively you may use `yarn`:
16
+
17
+
```sh
18
+
yarn add --dev graphql-tag.macro
19
+
```
20
+
21
+
Then, whenever you want to load `.gql` or `.graphql` files, import the `loader` from the macro package:
22
+
23
+
```js
24
+
import { loader } from'graphql.macro';
25
+
26
+
constquery=loader('./foo.graphql');
27
+
```
28
+
29
+
And your results get automatically inlined! This means that if the file above, `foo.graphql`, contains the following:
You can also use the `gql` template tag the same way you would use the non-macro version from `graphql-tag` package with the added benefit of inlined parsing results.
0 commit comments