@graphql-tools/webpack-loader 6.7.0-alpha-b76ec274.0 → 6.7.0-alpha-6c480b2d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# GraphQL Tools Webpack Loader
|
|
2
|
+
|
|
3
|
+
A webpack loader to preprocess GraphQL Documents (operations, fragments and SDL)
|
|
4
|
+
|
|
5
|
+
Slightly different fork of [graphql-tag/loader](https://github.com/apollographql/graphql-tag/pull/304).
|
|
6
|
+
|
|
7
|
+
yarn add @graphql-tools/webpack-loader
|
|
8
|
+
|
|
9
|
+
How is it different from `graphql-tag`? It removes locations entirely, doesn't include sources (string content of imported files), no warnings about duplicated fragment names and supports more custom scenarios.
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
- noDescription (_default: false_) - removes descriptions
|
|
14
|
+
- esModule (_default: false_) - uses import and export statements instead of CommonJS
|
|
15
|
+
|
|
16
|
+
## Importing GraphQL files
|
|
17
|
+
|
|
18
|
+
_To add support for importing `.graphql`/`.gql` files, see [Webpack loading and preprocessing](#webpack-loading-and-preprocessing) below._
|
|
19
|
+
|
|
20
|
+
Given a file `MyQuery.graphql`
|
|
21
|
+
|
|
22
|
+
```graphql
|
|
23
|
+
query MyQuery {
|
|
24
|
+
...
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If you have configured [the webpack @graphql-tools/webpack-loader](#webpack-loading-and-preprocessing), you can import modules containing graphQL queries. The imported value will be the pre-built AST.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import MyQuery from './query.graphql'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Preprocessing queries and fragments
|
|
35
|
+
|
|
36
|
+
Preprocessing GraphQL queries and fragments into ASTs at build time can greatly improve load times.
|
|
37
|
+
|
|
38
|
+
#### Webpack loading and preprocessing
|
|
39
|
+
|
|
40
|
+
Using the included `@graphql-tools/webpack-loader` it is possible to maintain query logic that is separate from the rest of your application logic. With the loader configured, imported graphQL files will be converted to AST during the webpack build process.
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
{
|
|
44
|
+
loaders: [
|
|
45
|
+
{
|
|
46
|
+
test: /\.(graphql|gql)$/,
|
|
47
|
+
exclude: /node_modules/,
|
|
48
|
+
loader: '@graphql-tools/webpack-loader',
|
|
49
|
+
options: {
|
|
50
|
+
/* ... */
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
}
|
|
55
|
+
```
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/webpack-loader",
|
|
3
|
-
"version": "6.7.0-alpha-
|
|
3
|
+
"version": "6.7.0-alpha-6c480b2d.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/optimize": "1.3.0-alpha-
|
|
11
|
-
"@graphql-tools/webpack-loader-runtime": "6.4.0-alpha-
|
|
10
|
+
"@graphql-tools/optimize": "1.3.0-alpha-6c480b2d.0",
|
|
11
|
+
"@graphql-tools/webpack-loader-runtime": "6.4.0-alpha-6c480b2d.0",
|
|
12
12
|
"tslib": "^2.4.0"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|