Skip to content

Commit 33dd716

Browse files
author
Sashko Stubailo
authored
Merge branch 'master' into patch-1
2 parents 1902577 + 2b5b737 commit 33dd716

File tree

14 files changed

+87
-31
lines changed

14 files changed

+87
-31
lines changed

docs/source/advanced/boost-migration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ import { InMemoryCache } from 'apollo-cache-inmemory';
132132
import { HttpLink } from 'apollo-link-http';
133133
import { onError } from 'apollo-link-error';
134134
import { withClientState } from 'apollo-link-state';
135-
import { ApolloLink } from 'apollo-link';
135+
import { ApolloLink, Observable } from 'apollo-link';
136136

137137
const cache = new InMemoryCache({
138138
cacheRedirects: {
@@ -154,7 +154,7 @@ const request = async (operation) => {
154154

155155
const requestLink = new ApolloLink((operation, forward) =>
156156
new Observable(observer => {
157-
let handle: any;
157+
let handle;
158158
Promise.resolve(operation)
159159
.then(oper => request(oper))
160160
.then(() => {
@@ -167,7 +167,7 @@ const requestLink = new ApolloLink((operation, forward) =>
167167
.catch(observer.error.bind(observer));
168168

169169
return () => {
170-
if (handle) handle.unsubscribe;
170+
if (handle) handle.unsubscribe();
171171
};
172172
})
173173
);

docs/source/advanced/caching.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ mutate({
303303
Using `update` gives you full control over the cache, allowing you to make changes to your data model in response to a mutation in any way you like. `update` is the recommended way of updating the cache after a query. It is explained in full [here](../api/react-apollo.html#graphql-mutation-options-update).
304304

305305
```javascript
306+
import CommentAppQuery from '../queries/CommentAppQuery';
307+
306308
const SUBMIT_COMMENT_MUTATION = gql`
307309
mutation submitComment($repoFullName: String!, $commentContent: String!) {
308310
submitComment(

docs/source/essentials/mutations.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ The render prop function that you pass to the `children` prop of `Mutation` is c
266266
<dd>Any errors returned from the mutation</dd>
267267
<dt>`called`: boolean</dt>
268268
<dd>A boolean indicating if the mutate function has been called</dd>
269+
<dt>`client`: ApolloClient</dt>
270+
<dd>Your `ApolloClient` instance. Useful for invoking cache methods outside the context of the update function, such as `client.writeData` and `client.readQuery`.</dd>
269271
</dl>
270272
271273
<h2 id="next-steps">Next steps</h2>

docs/source/recipes/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ app.use(cors(corsOptions));
3535
```
3636
## Header
3737

38-
Another common way to identify yourself when using HTTP is to send along an authorization header. Apollo Links allow to create middlewares that let you modify requests before they are sent to the server. It's easy to add an `authorization` header to every HTTP request. In this example, we'll pull the login token from `localStorage` every time a request is sent:
38+
Another common way to identify yourself when using HTTP is to send along an authorization header. It's easy to add an `authorization` header to every HTTP request by chaining together Apollo Links. In this example, we'll pull the login token from `localStorage` every time a request is sent:
3939

4040
```js
4141
import { ApolloClient } from 'apollo-client';

docs/source/recipes/babel.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ To avoid this runtime overhead, you can precompile your queries created with `gr
99
1. Using [babel-plugin-graphql-tag](#using-babel-plugin-graphql-tag)
1010
2. Using [graphql-tag.macro](#using-graphql-tagmacro)
1111

12+
If you prefer to keep your GraphQL code in separate files (`.graphql` or `.gql`) you can use [babel-plugin-inline-import-graphql-ast](https://github.com/detrohutt/babel-plugin-inline-import-graphql-ast). This plugin still uses `graphql-tag` under the hood, but transparently. You simply `import` your operations/fragments as if each were an export from your GraphQL file. This carries the same precompilation benefits as the above approaches.
13+
1214
## Using babel-plugin-graphql-tag
1315

1416
This approach will allow you to use the `graphql-tag` library as usual, and when processing the files with this babel plugin, the calls to that library will be replaced by the precompiled result.
@@ -69,9 +71,52 @@ const query = gql`
6971
`;
7072
```
7173

74+
## Using babel-plugin-graphql-tag
75+
76+
Install the plugin in your dev dependencies:
77+
78+
```
79+
# with npm
80+
npm install --save-dev babel-plugin-inline-import-graphql-ast
81+
82+
# or with yarn
83+
yarn add --dev babel-plugin-inline-import-graphql-ast
84+
```
85+
86+
Then add the plugin in your `.babelrc` configuration file:
87+
88+
```
89+
{
90+
"plugins": [
91+
"inline-import-graphql-ast"
92+
]
93+
}
94+
```
95+
96+
Now any `import` statements importing from a GraphQL file type will return a ready-to-use GraphQL DocumentNode object.
97+
98+
```javascript
99+
import React, { Component } from 'react';
100+
import { graphql } from 'react-apollo';
101+
import myImportedQuery from './productsQuery.graphql';
102+
// or for files with multiple operations:
103+
// import { query1, query2 } from './queries.graphql';
104+
105+
class QueryingComponent extends Component {
106+
render() {
107+
if (this.props.data.loading) return <h3>Loading...</h3>;
108+
return <div>{`This is my data: ${this.props.data.queryName}`}</div>;
109+
}
110+
}
111+
112+
export default graphql(myImportedQuery)(QueryingComponent);
113+
```
114+
72115
## Fragments
73116

74-
Both approaches work with fragments. You can have fragments defined in a different call to `gql` (either in the same file or in a different one). You can then include them into the main query using interpolation, like this:
117+
All of these approaches support the use of fragments.
118+
119+
For the first two approaches, you can have fragments defined in a different call to `gql` (either in the same file or in a different one). You can then include them into the main query using interpolation, like this:
75120

76121
```js
77122
import gql from 'graphql-tag';
@@ -97,3 +142,5 @@ const query = gql`
97142
${fragments.hello}
98143
`;
99144
```
145+
146+
With `babel-plugin-inline-import-graphql-ast`, you can just include your fragment in your GraphQL file along-side whatever uses it, or even import it from a separate file using the GraphQL `#import` syntax. See the [README](https://github.com/detrohutt/babel-plugin-inline-import-graphql-ast) for more information.

packages/apollo-boost/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apollo-boost",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "The easiest way to get started with Apollo Client",
55
"author": "Peggy Rayzis <peggy@apollographql.com>",
66
"contributors": [
@@ -33,8 +33,8 @@
3333
"filesize": "npm run build && npm run build:browser"
3434
},
3535
"dependencies": {
36-
"apollo-cache-inmemory": "^1.1.12",
37-
"apollo-client": "^2.2.8",
36+
"apollo-cache-inmemory": "^1.2.0",
37+
"apollo-client": "^2.3.0",
3838
"apollo-link": "^1.0.6",
3939
"apollo-link-error": "^1.0.3",
4040
"apollo-link-http": "^1.3.1",
@@ -44,7 +44,7 @@
4444
"devDependencies": {
4545
"@types/graphql": "0.12.7",
4646
"@types/jest": "21.1.10",
47-
"apollo-cache": "^1.1.7",
47+
"apollo-cache": "^1.1.8",
4848
"browserify": "15.2.0",
4949
"graphql": "0.13.2",
5050
"jest": "20.0.4",

packages/apollo-cache-inmemory/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change log
22

3-
### vNext
3+
### 1.2.0
44
- Various optimizations for cache read performance [#3300](https://github.com/apollographql/apollo-client/pull/3300)
55
- Fix typo in documentation
66

packages/apollo-cache-inmemory/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apollo-cache-inmemory",
3-
"version": "1.1.12",
3+
"version": "1.2.0",
44
"description": "Core abstract of Caching layer for Apollo Client",
55
"author": "James Baxley <james@meteor.com>",
66
"contributors": [
@@ -39,9 +39,9 @@
3939
"filesize": "npm run build:browser"
4040
},
4141
"dependencies": {
42-
"apollo-cache": "^1.1.7",
43-
"apollo-utilities": "^1.0.11",
44-
"graphql-anywhere": "^4.1.8"
42+
"apollo-cache": "^1.1.8",
43+
"apollo-utilities": "^1.0.12",
44+
"graphql-anywhere": "^4.1.9"
4545
},
4646
"peerDependencies": {
4747
"graphql": "0.11.7 || ^0.12.0 || ^0.13.0"

packages/apollo-cache/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apollo-cache",
3-
"version": "1.1.7",
3+
"version": "1.1.8",
44
"description": "Core abstract of Caching layer for Apollo Client",
55
"author": "James Baxley <james@meteor.com>",
66
"contributors": [
@@ -38,7 +38,7 @@
3838
"filesize": "npm run build && npm run build:browser"
3939
},
4040
"dependencies": {
41-
"apollo-utilities": "^1.0.11"
41+
"apollo-utilities": "^1.0.12"
4242
},
4343
"devDependencies": {
4444
"@types/graphql": "0.12.7",

packages/apollo-client/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Change log
33

4-
### vNEXT
4+
### 2.3.0
55
- fixed edge case bug of changing fetchPolicies right after resetStore with no variables present
66
- Various optimizations for cache read performance [#3300](https://github.com/apollographql/apollo-client/pull/3300)
77

packages/apollo-client/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "apollo-client",
33
"private": true,
4-
"version": "2.2.8",
4+
"version": "2.3.0",
55
"description": "A simple yet functional GraphQL client.",
66
"main": "./lib/bundle.umd.js",
77
"module": "./lib/index.js",
@@ -46,10 +46,10 @@
4646
"license": "MIT",
4747
"dependencies": {
4848
"@types/zen-observable": "^0.5.3",
49-
"apollo-cache": "^1.1.7",
49+
"apollo-cache": "^1.1.8",
5050
"apollo-link": "^1.0.0",
5151
"apollo-link-dedup": "^1.0.0",
52-
"apollo-utilities": "^1.0.11",
52+
"apollo-utilities": "^1.0.12",
5353
"symbol-observable": "^1.0.2",
5454
"zen-observable": "^0.8.0"
5555
},
@@ -63,7 +63,7 @@
6363
"@types/jest": "21.1.10",
6464
"@types/lodash": "4.14.108",
6565
"@types/node": "8.10.11",
66-
"apollo-cache-inmemory": "^1.1.12",
66+
"apollo-cache-inmemory": "^1.2.0",
6767
"benchmark": "2.1.4",
6868
"browserify": "15.2.0",
6969
"bundlesize": "0.17.0",

packages/apollo-utilities/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apollo-utilities",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "Utilities for working with GraphQL ASTs",
55
"author": "James Baxley <james@meteor.com>",
66
"contributors": [

packages/graphql-anywhere/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change log
22

3-
## vNEXT
3+
## 4.1.9
44
- Various optimizations for cache read performance [#3300](https://github.com/apollographql/apollo-client/pull/3300)
55

66
### 4.1.8

packages/graphql-anywhere/package.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-anywhere",
3-
"version": "4.1.8",
3+
"version": "4.1.9",
44
"description": "Run GraphQL queries with no schema and just one resolver",
55
"main": "./lib/bundle.umd.js",
66
"module": "./lib/index.js",
@@ -15,10 +15,8 @@
1515
"watch": "tsc -w",
1616
"prepublishOnly": "npm run build",
1717
"lint": "tslint --type-check -p tsconfig.json src/*.ts",
18-
"build:browser":
19-
"browserify ./lib/bundle.umd.js -o=./lib/bundle.js --i apollo-utilities && npm run minify:browser",
20-
"minify:browser":
21-
"uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js",
18+
"build:browser": "browserify ./lib/bundle.umd.js -o=./lib/bundle.js --i apollo-utilities && npm run minify:browser",
19+
"minify:browser": "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js",
2220
"filesize": "npm run build:browser"
2321
},
2422
"repository": {
@@ -35,10 +33,12 @@
3533
"react"
3634
],
3735
"author": "Sashko Stubailo <sashko@stubailo.com>",
38-
"contributors": ["James Burgess <jamesmillerburgess@gmail.com>"],
36+
"contributors": [
37+
"James Burgess <jamesmillerburgess@gmail.com>"
38+
],
3939
"license": "MIT",
4040
"dependencies": {
41-
"apollo-utilities": "^1.0.11"
41+
"apollo-utilities": "^1.0.12"
4242
},
4343
"devDependencies": {
4444
"@types/graphql": "0.12.7",
@@ -65,6 +65,11 @@
6565
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
6666
},
6767
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
68-
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
68+
"moduleFileExtensions": [
69+
"ts",
70+
"tsx",
71+
"js",
72+
"json"
73+
]
6974
}
7075
}

0 commit comments

Comments
 (0)