Skip to content

Commit

Permalink
Merge branch 'master' into graphql-peer-dependency-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
hwillson authored Jul 10, 2018
2 parents aeeb6d3 + 7076e36 commit 0497c5f
Show file tree
Hide file tree
Showing 26 changed files with 187 additions and 62 deletions.
52 changes: 51 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
**Note:** This is a cumulative changelog that outlines all of the Apollo Client project child package changes that were bundled into a specific `apollo-client` release.

### 2.3.4 (June 13, 2018)
## vNext

### Apollo Client (vNext)

- Documentation updates.
[@ananth99](https://github.com/ananth99) in [#3599](https://github.com/apollographql/apollo-client/pull/3599)
[@hwillson](https://github.com/hwillson) in [#3635](https://github.com/apollographql/apollo-client/pull/3635)
[@JakeDawkins](https://github.com/JakeDawkins) in [#3642](https://github.com/apollographql/apollo-client/pull/3642)
[@hwillson](https://github.com/hwillson) in [#3644](https://github.com/apollographql/apollo-client/pull/3644)

### Apollo Boost (vNext)

- Allow `fetch` to be given as a configuration option to `ApolloBoost`.
[@mbaranovski](https://github.com/mbaranovski) in [#3590](https://github.com/apollographql/apollo-client/pull/3590)

## 2.3.5 (June 19, 2018)

### Apollo Client (2.3.5)

- Internal code formatting updates.
- [@chentsulin](https://github.com/chentsulin) in [#3574](https://github.com/apollographql/apollo-client/pull/3574)
- Documentation updates.
- [@andtos90](https://github.com/andtos90) in [#3596](https://github.com/apollographql/apollo-client/pull/3596)
- [@serranoarevalo](https://github.com/serranoarevalo) in [#3554](https://github.com/apollographql/apollo-client/pull/3554)
- [@cooperka](https://github.com/cooperka) in [#3594](https://github.com/apollographql/apollo-client/pull/3594)
- [@pravdomil](https://github.com/pravdomil) in [#3587](https://github.com/apollographql/apollo-client/pull/3587)
- [@excitement-engineer](https://github.com/excitement-engineer) in [#3309](https://github.com/apollographql/apollo-client/pull/3309)

### Apollo Boost (0.1.10)

- No changes.

### Apollo Cache (1.1.12)

- No changes.

### Apollo Cache In-Memory (1.2.5)

- No changes.

### Apollo Utilities (1.0.16)

- Removed unnecessary whitespace from error message.
- [@mbaranovski](https://github.com/mbaranovski) in [#3593](https://github.com/apollographql/apollo-client/pull/3593)

### Apollo GraphQL Anywhere (4.1.14)

- No changes.


## 2.3.4 (June 13, 2018)

### Apollo Client (2.3.4)

Expand Down
7 changes: 7 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ sidebar_categories:
- recipes/webpack
- recipes/meteor
- recipes/recompose
Related Guides:
- title: State Management
href: https://www.apollographql.com/docs/guides/state-mgmt.html
- title: Testing React Components
href: https://www.apollographql.com/docs/guides/testing-react-components.html
- title: Schema Design
href: https://www.apollographql.com/docs/guides/schema-design.html
API:
- api/apollo-client
- api/react-apollo
Expand Down
6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"hexo-server": "0.3.2",
"hexo-typescript-api-box": "0.9.2",
"poke-site": "1.3.1",
"start-server-and-test": "1.4.1",
"meteor-theme-hexo": "1.0.13",
"start-server-and-test": "1.5.0",
"meteor-theme-hexo": "1.0.16",
"typedoc": "0.9.0",
"typescript": "2.8.3"
"typescript": "2.9.2"
},
"scripts": {
"start": "npm run build && chexo apollo-hexo-config -- server",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/advanced/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The `InMemoryCache` constructor takes an optional config object with properties
- `addTypename`: A boolean to determine whether to add __typename to the document (default: `true`)
- `dataIdFromObject`: A function that takes a data object and returns a unique identifier to be used when normalizing the data in the store. Learn more about how to customize `dataIdFromObject` in the [Normalization](#normalization) section.
- `fragmentMatcher`: By default, the `InMemoryCache` uses a heuristic fragment matcher. If you are using fragments on unions and interfaces, you will need to use an `IntrospectionFragmentMatcher`. For more information, please read [our guide to setting up fragment matching for unions & interfaces](./fragments.html#fragment-matcher).
- `cacheRedirects` (previously known as `cacheResolvers` or `customResolvers`): An map of functions to redirect a query to another entry in the cache before a request takes place. This is useful if you have a list of items and want to use the data from the list query on a detail page where you're querying an individual item. More on that [here](https://www.apollographql.com/docs/react/advanced/caching.html#cacheRedirect).
- `cacheRedirects` (previously known as `cacheResolvers` or `customResolvers`): A map of functions to redirect a query to another entry in the cache before a request takes place. This is useful if you have a list of items and want to use the data from the list query on a detail page where you're querying an individual item. More on that [here](https://www.apollographql.com/docs/react/advanced/caching.html#cacheRedirect).

<h3 id="normalization">Normalization</h3>

Expand Down
1 change: 1 addition & 0 deletions docs/source/api/apollo-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The `ApolloClient` class is the core API for Apollo, and the one you'll need to
{% tsapibox ApolloClient.watchQuery %}
{% tsapibox ApolloClient.query %}
{% tsapibox ApolloClient.mutate %}
{% tsapibox ApolloClient.subscribe %}
{% tsapibox ApolloClient.readQuery %}
{% tsapibox ApolloClient.readFragment %}
{% tsapibox ApolloClient.writeQuery %}
Expand Down
12 changes: 11 additions & 1 deletion docs/source/api/react-apollo.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ The Query component accepts the following props. Only `query` and `children` are
<dd>The name of your component to be displayed in React DevTools. Defaults to 'Query'.</dd>
<dt>`skip`: boolean</dt>
<dd>If skip is true, the query will be skipped entirely.</dd>
<dt>`onCompleted`: (data: TData | {}) => void</dt>
<dd>A callback executed once your query successfully completes.</dd>
<dt>`onError`: (error: ApolloError) => void</dt>
<dd>A callback executed in the event of an error.</dd>
<dt>`context`: Record<string, any></dt>
<dd>Shared context between your Query component and your network interface (Apollo Link). Useful for setting headers from props or sending information to the `request` function of Apollo Boost.</dd>
</dl>
Expand Down Expand Up @@ -1086,14 +1090,20 @@ export default graphql(gql`

This option allows you to update your store based on your mutation’s result. By default Apollo Client will update all of the overlapping nodes in your store. Anything that shares the same id as returned by the `dataIdFromObject` you defined will be updated with the new fields from your mutation results. However, sometimes this alone is not sufficient. Sometimes you may want to update your cache in a way that is dependent on the data currently in your cache. For these updates you may use an `options.update` function.

`options.update` takes two arguments. The first is an instance of a [`DataProxy`][] object which has some methods which will allow you to interact with the data in your store. The second is the response from your mutation - either the optimistic response, or the actual response returned by your server.
`options.update` takes two arguments. The first is an instance of a [`DataProxy`][] object which has some methods which will allow you to interact with the data in your store. The second is the response from your mutation - either the optimistic response, or the actual response returned by your server (see the mutation result described in the [mutation render prop](./react-apollo.html#mutation-render-prop) section for more details).

In order to change the data in your store call methods on your [`DataProxy`][] instance like [`writeQuery`][] and [`writeFragment`][]. This will update your cache and reactively re-render any of your GraphQL components which are querying affected data.

To read the data from the store that you are changing, make sure to use methods on your [`DataProxy`][] like [`readQuery`][] and [`readFragment`][].

For more information on updating your cache after a mutation with the `options.update` function make sure to read the [Apollo Client technical documentation on the subject](../advanced/caching.html#updating-the-cache-after-a-mutation).

[`DataProxy`]: ../advanced/caching.html#direct
[`writeQuery`]: ../advanced/caching.html#writequery-and-writefragment
[`writeFragment`]: ../advanced/caching.html#writequery-and-writefragment
[`readQuery`]: ../advanced/caching.html#readquery
[`readFragment`]: ../advanced/caching.html#readfragment

**Example:**

```js
Expand Down
2 changes: 2 additions & 0 deletions docs/source/essentials/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ Here are the options you can pass to the `ApolloClient` exported from `apollo-bo
<dd>Is set to `same-origin` by default. This option can be used to indicate whether the user agent should send cookies with requests. See [Request.credentials](https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials) for more details.</dd>
<dt>`headers`: Object</dt>
<dd>Header key/value pairs to pass along with the request.</dd>
<dt>`fetch`: GlobalFetch['fetch']</dt>
<dd>A [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) compatible API for making a request.</dd>
</dl>
<h2 id="next-steps">Next steps</h2>
Expand Down
2 changes: 1 addition & 1 deletion docs/source/essentials/local-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ const Detail = ({ match: { params: { breed, id } } }) => (
);
```

<h2 id="queries">Next steps</h2>
<h2 id="next-steps">Next steps</h2>

Managing your local data with Apollo Client can simplify your state management code since the Apollo cache is your single source of truth for all data in your application. If you'd like to learn more about `apollo-link-state`, check out:

Expand Down
2 changes: 2 additions & 0 deletions docs/source/essentials/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ The Query component accepts the following props. Only `query` and `children` are
<dd>The name of your component to be displayed in React DevTools. Defaults to 'Query'.</dd>
<dt>`delay`: boolean</dt>
<dd>If `delay` is true, the `Query` component will not fetch the query on mount although its children will still render. Use `delay` with `load` in the render prop function to manually fire the query.</dd>
<dt>`skip`: boolean</dt>
<dd>If skip is true, the query will be skipped entirely.</dd>
<dt>`context`: Record<string, any></dt>
<dd>Shared context between your Query component and your network interface (Apollo Link). Useful for setting headers from props or sending information to the `request` function of Apollo Boost.</dd>
</dl>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@
"devDependencies": {
"bundlesize": "0.17.0",
"check-if-folder-contents-changed-in-git-commit-range": "1.0.0",
"codecov": "3.0.2",
"codecov": "3.0.3",
"danger": "1.2.0",
"jest-junit": "4.0.0",
"lerna": "2.11.0",
"lint-staged": "6.1.0",
"pre-commit": "1.2.2",
"prettier": "1.12.1",
"prettier": "1.13.7",
"rollup-plugin-local-resolve": "1.0.7",
"rollup-plugin-node-resolve": "3.3.0",
"rollup-plugin-sourcemaps": "0.4.2",
"ts-jest": "20.0.14",
"typescript": "2.8.3"
"typescript": "2.9.2"
}
}
12 changes: 11 additions & 1 deletion packages/apollo-boost/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# CHANGELOG

### vNext

- Allow `fetch` to be given as a configuration option to ApolloBoost.
[Issue #3578](https://github.com/apollographql/apollo-client/issues/3578)
[PR #3590](https://github.com/apollographql/apollo-client/pull/3590)

### 0.1.10

- No changes.

### 0.1.9

- No changes
- No changes.

### 0.1.8

Expand Down
14 changes: 7 additions & 7 deletions packages/apollo-boost/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-boost",
"version": "0.1.9",
"version": "0.1.10",
"description": "The easiest way to get started with Apollo Client",
"author": "Peggy Rayzis <peggy@apollographql.com>",
"contributors": [
Expand Down Expand Up @@ -34,9 +34,9 @@
"filesize": "npm run build && npm run build:browser"
},
"dependencies": {
"apollo-cache": "^1.1.11",
"apollo-cache-inmemory": "^1.2.4",
"apollo-client": "^2.3.4",
"apollo-cache": "^1.1.12",
"apollo-cache-inmemory": "^1.2.5",
"apollo-client": "^2.3.5",
"apollo-link": "^1.0.6",
"apollo-link-error": "^1.0.3",
"apollo-link-http": "^1.3.1",
Expand All @@ -46,16 +46,16 @@
"devDependencies": {
"@types/graphql": "0.12.7",
"@types/jest": "22.2.3",
"apollo-utilities": "^1.0.15",
"apollo-utilities": "^1.0.16",
"browserify": "15.2.0",
"fetch-mock": "6.4.3",
"fetch-mock": "6.5.0",
"graphql": "0.13.2",
"jest": "23.0.0",
"lodash": "4.17.10",
"rimraf": "2.6.2",
"ts-jest": "20.0.14",
"tslint": "5.10.0",
"typescript": "2.8.3",
"typescript": "2.9.2",
"uglifyjs": "2.4.11"
},
"jest": {
Expand Down
18 changes: 17 additions & 1 deletion packages/apollo-boost/src/__tests__/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ApolloClient, { gql, InMemoryCache } from '../';
import { stripSymbols } from 'apollo-utilities';
import { HttpLink } from 'apollo-link-http';
import * as fetchMock from 'fetch-mock';

global.fetch = jest.fn(() =>
Expand All @@ -22,6 +21,23 @@ describe('config', () => {
},
};

it('allows you to pass in a custom fetcher', () => {
const customFetcher = jest.fn(() =>
Promise.resolve({
text: () => Promise.resolve('{"data": {"foo": "bar" }}'),
}),
);

const client = new ApolloClient({
fetch: customFetcher,
});

client.query({ query }).then(({ data }) => {
expect(customFetcher).toHaveBeenCalledTimes(1);
expect(stripSymbols(data)).toEqual({ foo: 'bar' });
});
});

it('allows you to pass in a request handler', () => {
let requestCalled;

Expand Down
3 changes: 3 additions & 0 deletions packages/apollo-boost/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface PresetConfig {
uri?: string;
credentials?: string;
headers?: any;
fetch?: GlobalFetch['fetch'];
fetchOptions?: HttpLink.Options;
clientState?: ClientStateConfig;
onError?: ErrorLink.ErrorHandler;
Expand All @@ -34,6 +35,7 @@ export default class DefaultClient<TCache> extends ApolloClient<TCache> {
uri,
credentials,
headers,
fetch,
fetchOptions,
clientState,
cacheRedirects,
Expand Down Expand Up @@ -104,6 +106,7 @@ export default class DefaultClient<TCache> extends ApolloClient<TCache> {

const httpLink = new HttpLink({
uri: uri || '/graphql',
fetch,
fetchOptions: fetchOptions || {},
credentials: credentials || 'same-origin',
headers: headers || {},
Expand Down
6 changes: 5 additions & 1 deletion packages/apollo-cache-inmemory/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# CHANGELOG

### 1.2.5

- No changes.

### 1.2.4

- No changes
- No changes.

### 1.2.3

Expand Down
14 changes: 7 additions & 7 deletions packages/apollo-cache-inmemory/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-cache-inmemory",
"version": "1.2.4",
"version": "1.2.5",
"description": "Core abstract of Caching layer for Apollo Client",
"author": "James Baxley <james@meteor.com>",
"contributors": [
Expand Down Expand Up @@ -40,27 +40,27 @@
"filesize": "npm run build:browser"
},
"dependencies": {
"apollo-cache": "^1.1.11",
"apollo-utilities": "^1.0.15",
"graphql-anywhere": "^4.1.13"
"apollo-cache": "^1.1.12",
"apollo-utilities": "^1.0.16",
"graphql-anywhere": "^4.1.14"
},
"peerDependencies": {
"graphql": "0.11.7 || ^0.12.0 || ^0.13.0"
},
"devDependencies": {
"@types/graphql": "0.12.7",
"@types/jest": "22.2.3",
"@types/lodash": "4.14.109",
"@types/lodash": "4.14.110",
"browserify": "15.2.0",
"graphql": "0.13.2",
"graphql-tag": "2.9.2",
"jest": "23.0.0",
"lodash": "4.17.10",
"rimraf": "2.6.2",
"rollup": "0.59.4",
"rollup": "0.62.0",
"ts-jest": "20.0.14",
"tslint": "5.10.0",
"typescript": "2.8.3",
"typescript": "2.9.2",
"uglifyjs": "2.4.11"
},
"jest": {
Expand Down
6 changes: 5 additions & 1 deletion packages/apollo-cache/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# CHANGELOG

### 1.1.12

- No changes.

### 1.1.11

- No changes
- No changes.

### 1.1.10

Expand Down
Loading

0 comments on commit 0497c5f

Please sign in to comment.