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
- Fix #61: split('/n') does not work on Windows [dnalborczyk](https://github.com/dnalborczyk) in [PR #89](https://github.com/apollographql/graphql-tag/pull/89)
42
+
43
+
* Fix #61: split('/n') does not work on Windows [dnalborczyk](https://github.com/dnalborczyk) in
- Add support for calling `gql` as a function [matthewerwin](https://github.com/matthewerwin) in [PR #66](https://github.com/apollographql/graphql-tag/pull/66)
41
-
- Including yarn.lock file [PowerKiKi](https://github.com/PowerKiKi) in [PR #72](https://github.com/apollographql/graphql-tag/pull/72)
42
-
- Ignore duplicate fragments when using the Webpack loader [czert](https://github.com/czert) in [PR #52](https://github.com/apollographql/graphql-tag/pull/52)
43
-
- Fixing `graphql-tag/loader` by properly stringifying GraphQL Source [jnwng](https://github.com/jnwng) in [PR #65](https://github.com/apollographql/graphql-tag/pull/65)
52
+
53
+
* Add support for calling `gql` as a function [matthewerwin](https://github.com/matthewerwin) in
- Add typescript definitions for the bundledPrinter [PR #63](https://github.com/apollographql/graphql-tag/pull/63)
72
+
73
+
* Add typescript definitions for the bundledPrinter [PR #63](https://github.com/apollographql/graphql-tag/pull/63)
51
74
52
75
### v1.3.1
53
-
- Making sure not to log deprecation warnings for internal use of deprecated module [jnwng](https://github.com/jnwng) addressing [#54](https://github.com/apollographql/graphql-tag/issues/54#issuecomment-283301475)
76
+
77
+
* Making sure not to log deprecation warnings for internal use of deprecated module [jnwng](https://github.com/jnwng)
- Bump bundled `graphql` packages to v0.9.1 [jnwng](https://github.com/jnwng) in [PR #55](https://github.com/apollographql/graphql-tag/pull/55).
57
-
- Deprecate the `graphql/language/parser` and `graphql/language/printer` exports [jnwng](https://github.com/jnwng) in [PR #55](https://github.com/apollographql/graphql-tag/pull/55)
81
+
82
+
* Bump bundled `graphql` packages to v0.9.1 [jnwng](https://github.com/jnwng) in
[](http://www.apollodata.com/#slack)
5
5
6
-
GraphQL printing and parsing with bundled dependencies. Includes:
6
+
Helpful utilities for parsing GraphQL queries. Includes:
7
7
8
8
-`gql` A JavaScript template literal tag that parses GraphQL query strings into the standard GraphQL AST.
9
9
-`/loader` A webpack loader to preprocess queries
10
10
11
+
`graphql-tag` uses [the reference `graphql` library](https://github.com/graphql/graphql-js) under the hood as a peer dependency, so in addition to installing this module, you'll also have to install `graphql-js`.
12
+
11
13
### gql
12
14
13
15
This is a template literal tag you can use to concisely write a GraphQL query that is parsed into the standard GraphQL AST:
@@ -62,9 +64,35 @@ That's where this package comes in - it lets you write your queries with [ES2015
62
64
63
65
This package only has one feature - it caches previous parse results in a simple dictionary. This means that if you call the tag on the same query multiple times, it doesn't waste time parsing it again. It also means you can use `===` to compare queries to check if they are identical.
64
66
65
-
### Webpack preprocessing
67
+
### Babel preprocessing
68
+
69
+
GraphQL queries can be compiled at build time using [babel-plugin-graphql-tag](https://github.com/gajus/babel-plugin-graphql-tag). Pre-compiling queries decreases the script initialization time and reduces the bundle size by potentially removing the need for `graphql-tag` at runtime.
70
+
71
+
#### TypeScript
72
+
Try this custom transformer to pre-compile your GraphQL queries in TypeScript: [ts-transform-graphql-tag](https://github.com/firede/ts-transform-graphql-tag).
73
+
74
+
#### React Native, Next.js
66
75
67
-
This package also includes a [webpack loader](https://webpack.github.io/docs/loaders.html). There are many benefits over this approach, which saves GraphQL ASTs processing time on client-side and enable queries to be separated from script over `.graphql` files.
76
+
Additionally, in certain situations, preprocessing queries via the webpack loader is not possible. [babel-plugin-inline-import-graphql-ast](https://www.npmjs.com/package/babel-plugin-inline-import-graphql-ast) will allow one to import graphql files directly into your JavaScript by preprocessing GraphQL queries into ASTs at compile-time.
`[email protected]` will [support the ability to preprocess queries](https://github.com/facebook/create-react-app/pull/3909) using `graphql-tag/loader` without the need to eject.
90
+
91
+
If you're using an older version of `create-react-app`, check out [react-app-rewire-inline-import-graphql-ast](https://www.npmjs.com/package/react-app-rewire-inline-import-graphql-ast) to preprocess queries without needing to eject.
92
+
93
+
### Webpack preprocessing with `graphql-tag/loader`
94
+
95
+
This package also includes a [webpack loader](https://webpack.js.org/concepts/loaders). There are many benefits over this approach, which saves GraphQL ASTs processing time on client-side and enable queries to be separated from script over `.graphql` files.
68
96
69
97
```js
70
98
loaders: [
@@ -88,3 +116,33 @@ console.log(query);
88
116
```
89
117
90
118
Testing environments that don't support Webpack require additional configuration. For [Jest](https://facebook.github.io/jest/) use [jest-transform-graphql](https://github.com/remind101/jest-transform-graphql).
119
+
120
+
#### Support for multiple operations
121
+
122
+
With the webpack loader, you can also import operations by name:
123
+
124
+
In a file called `query.gql`:
125
+
```graphql
126
+
queryMyQuery1 {
127
+
...
128
+
}
129
+
130
+
queryMyQuery2 {
131
+
...
132
+
}
133
+
```
134
+
135
+
And in your JavaScript:
136
+
```javascript
137
+
import { MyQuery1, MyQuery2 } from'query.gql'
138
+
```
139
+
140
+
### Warnings
141
+
142
+
This package will emit a warning if you have multiple fragments of the same name. You can disable this with:
0 commit comments