Skip to content

Commit

Permalink
Merge branch 'main' into release-3.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed May 26, 2022
2 parents a6ace50 + a9226c1 commit 895e028
Show file tree
Hide file tree
Showing 12 changed files with 550 additions and 131 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
- Replace `concast.cleanup` method with simpler `concast.beforeNext` API, which promises to call the given callback function just before the next result/error is delivered. In addition, `concast.removeObserver` no longer takes a `quietly?: boolean` parameter, since that parameter was partly responsible for cleanup callbacks sometimes not getting called. <br/>
[@benjamn](https://github.com/benjamn) in [#9718](https://github.com/apollographql/apollo-client/pull/9718)

## Apollo Client 3.6.5 (unreleased)
## Apollo Client 3.6.6 (2022-05-26)

### Bug Fixes

- Allow `useLazyQuery(query, { defaultOptions })` to benefit from `defaultOptions.variables` and `client.defaultOptions.watchQuery.variables` merging. <br/>
[@benjamn](https://github.com/benjamn) in [#9762](https://github.com/apollographql/apollo-client/pull/9762)

## Apollo Client 3.6.5 (2022-05-23)

### Bug Fixes

Expand All @@ -18,9 +25,15 @@
- Preserve `previousData` even when different query or client provided to `useQuery`, instead of resetting `previousData` to undefined in those cases, matching behavior prior to v3.6.0. <br/>
[@benjamn](https://github.com/benjamn) in [#9734](https://github.com/apollographql/apollo-client/pull/9734)

- Fix bug where `onCompleted()` and `onError()` are stale for `useMutation()`. <br/>
[@charle692](https://github.com/charle692) in [#9740](https://github.com/apollographql/apollo-client/pull/9740)

- Limit scope of `DeepMerger` object reuse, and avoid using `Object.isFrozen`, which can introduce differences between development and production if objects that were frozen using `Object.freeze` in development are left unfrozen in production. <br/>
[@benjamn](https://github.com/benjamn) in [#9742](https://github.com/apollographql/apollo-client/pull/9742)

- Properly merge `variables` from original `useLazyQuery(query, { variables })` with `variables` passed to execution function. <br/>
[@benjamn](https://github.com/benjamn) in [#9758](https://github.com/apollographql/apollo-client/pull/9758)

## Apollo Client 3.6.4 (2022-05-16)

### Bug Fixes
Expand Down
27 changes: 27 additions & 0 deletions docs/source/data/file-uploads.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: File uploads
description: Enabling file uploads in Apollo Client
---

Apollo Client doesn't support a file upload feature out of the box. If you'd like to enable file upload capabilities, you will have to set Apollo Client up manually with a 3rd party package.

Detailed instructions on how to setup Apollo Client for file upload can be found here: [https://github.com/jaydenseric/apollo-upload-client](https://github.com/jaydenseric/apollo-upload-client).

An example configuration is show below using the [apollo-upload-client](https://github.com/jaydenseric/apollo-upload-client) package.

```bash
npm install apollo-upload-client
```

Basic setup for the Apollo Client:

```js
const { ApolloClient } = require('apollo-client')
const { InMemoryCache } = require('apollo-cache-inmemory')
const { createUploadLink } = require('apollo-upload-client')

const client = new ApolloClient({
cache: new InMemoryCache(),
link: createUploadLink()
})
```
2 changes: 1 addition & 1 deletion docs/source/data/queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ We've already seen that the `useQuery` hook exposes our query's current loading
Let's return to our refetching example from the previous section. If you click the refetch button, you'll see that the component doesn't re-render until the new data arrives. What if we want to indicate to the user that we're refetching the photo?

The `useQuery` hook's result object provides fine-grained information about the status of the query via the `networkStatus` property. To take advantage
of this information, we set the `notifyOnNetworkStatusChange` option to `true` so our query component re-renders while a refetch is in flight:
of this information, we set the `notifyOnNetworkStatusChange` option to `true` so our [query component](../api/react/components/ "Components - Client (React) - Apollo GraphQL Docs") re-renders while a refetch is in flight:

```jsx title="index.js" {4,8,12}
import { NetworkStatus } from '@apollo/client';
Expand Down
4 changes: 2 additions & 2 deletions docs/source/development-testing/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ it('should render loading state initially', () => {
query: DELETE_DOG_MUTATION,
variables: { name: 'Buck' },
},
result: { data: { deleteDog } },
result: { data: deleteDog },
},
];

Expand Down Expand Up @@ -357,7 +357,7 @@ it('should delete and give visual feedback', async () => {
query: DELETE_DOG_MUTATION,
variables: { name: 'Buck' },
},
result: { data: { deleteDog } },
result: { data: deleteDog },
},
];

Expand Down
12 changes: 7 additions & 5 deletions docs/source/networking/advanced-http-networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,29 @@ In this example, the user is logged out of the application if the server returns

### Modifying response data

You can create a custom link that adds, edits, or removes fields from `response.data`. To do so, you call `map` on the result of the link's `forward(operation)` call. In the `map` function, make any desired changes to `response.data` and then return it:
You can create a custom link that edits or removes fields from `response.data`. To do so, you call `map` on the result of the link's `forward(operation)` call. In the `map` function, make the desired changes to `response.data` and then return it:

```js
import { ApolloClient, InMemoryCache, HttpLink, ApolloLink } from '@apollo/client';

const httpLink = new HttpLink({ uri: '/graphql' });

const addDateLink = new ApolloLink((operation, forward) => {
const formatDateLink = new ApolloLink((operation, forward) => {
return forward(operation).map(response => {
response.data.date = new Date();
if (response.data.date) {
response.data.date = new Date(response.data.date);
}
return response;
});
});

const client = new ApolloClient({
cache: new InMemoryCache(),
link: addDateLink.concat(httpLink),
link: formatDateLink.concat(httpLink),
});
```

In the above example, `addDateLink` adds a `date` field to the top level of each response.
In the above example, `formatDateLink` changes a `date` field to a Javascript Date object at the top level of each response.

Note that `forward(operation).map(func)` _doesn't_ support asynchronous execution of the `func` mapping function. If you need to make asynchronous modifications, use the `asyncMap` function from `@apollo/client/utilities`, like so:

Expand Down
Loading

0 comments on commit 895e028

Please sign in to comment.