Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
jpvajda authored May 11, 2022
2 parents 8a52be8 + 0d47b1c commit 2e58f60
Show file tree
Hide file tree
Showing 32 changed files with 1,193 additions and 415 deletions.
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
## Apollo Client 3.6.4 (unreleased)

### Bug Fixes

- Guarantee `Concast` cleanup without `Observable cancelled prematurely` rejection, potentially solving long-standing issues involving that error. <br/>
[@benjamn](https://github.com/benjamn) in [#9701](https://github.com/apollographql/apollo-client/pull/9701)

### Improvements

- Internalize `useSyncExternalStore` shim, for more control than `use-sync-external-store` provides, fixing some React Native issues. <br/>
[@benjamn](https://github.com/benjamn) in [#9675](https://github.com/apollographql/apollo-client/pull/9675)

## Apollo Client 3.6.3 (unreleased)

### Bug Fixes

- Simplify `useQuery(query, { defaultOptions })` default options processing in order to fix bug where `skip: true` queries failed to execute upon switching to `skip: false`. <br/>
[@benjamn](https://github.com/benjamn) in [#9665](https://github.com/apollographql/apollo-client/pull/9665)

- Add tests of skipping/unskipping and `useLazyQuery` with `defaultOptions`, and fix a bug causing duplicate requests. <br/>
[@benjamn](https://github.com/benjamn) in [#9666](https://github.com/apollographql/apollo-client/pull/9666)

- Update `ts-invariant` to version 0.10.2 to fix source map warnings. <br/>
[@benjamn](https://github.com/benjamn) in [#9672](https://github.com/apollographql/apollo-client/pull/9672)

- Test that `useQuery` queries with `skip: true` do not stall server-side rendering. <br/>
[@nathanmarks](https://github.com/nathanmarks) and [@benjamn](https://github.com/benjamn) in [#9677](https://github.com/apollographql/apollo-client/pull/9677)

- Prevent `useLazyQuery` from making duplicate requests when its execution function is first called, and stop rejecting the `Promise` it returns when `result.error` is defined. <br/>
[@benjamn](https://github.com/benjamn) in [#9684](https://github.com/apollographql/apollo-client/pull/9684)

- Fix issue with `useQuery` returning `loading: true` state during server-side rendering with `skip: true`. <br/>
[@nathanmarks](https://github.com/nathanmarks) in [#9679](https://github.com/apollographql/apollo-client/pull/9679)

## Apollo Client 3.6.2 (2022-05-02)

### Bug Fixes

- Pass `getServerSnapshot` function to `useSyncExternalStore` in addition to `getSnapshot`, though the two functions behave identically. This change should fix/unbreak React 18 server rendering. <br/>
[@hungphongbk](https://github.com/hungphongbk) in [#9652](https://github.com/apollographql/apollo-client/pull/9652)

### Improvements

- Consider `networkError.result.errors` in addition to `result.errors` in `PersistedQueryLink`. <br/>
[@redaid113](https://github.com/redaid113) and [@benjamn](https://github.com/benjamn) in [#9410](https://github.com/apollographql/apollo-client/pull/9410)

## Apollo Client 3.6.1 (2022-04-28)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
Copyright (c) 2022 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For up to date release notes, refer to the project's [Change Log](https://github

1. Web Cache and performance improvements through new hooks (useBackgroundQuery, useFragment)
- [#8694](https://github.com/apollographql/apollo-client/issues/8694)
- [#8263](https://github.com/apollographql/apollo-client/issues/8263)
- [#8236](https://github.com/apollographql/apollo-client/issues/8236)
2. RefetchQueries not working when using string array after mutation
- [#5419](https://github.com/apollographql/apollo-client/issues/5419)
3. Adding React suspense + data fetching support
Expand Down
16 changes: 16 additions & 0 deletions docs/source/api/core/ApolloClient.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ See the [example object below](#example-defaultoptions-object).
</td>
</tr>


<tr>
<td>

###### `assumeImmutableResults`

`Boolean`
</td>
<td>

If `true`, Apollo Client will assume results read from the cache are never mutated by application code, which enables substantial performance optimizations.

The default value is `false`.
</td>
</tr>

</tbody>
</table>

Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/link/apollo-link-batch-http.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ The context `http` object currently supports two keys:
* `includeExtensions`: Send the extensions object for this request.
* `includeQuery`: Don't send the `query` field for this request.

One way to use persisted queries is with [apollo-link-persisted-queries](https://github.com/apollographql/apollo-link-persisted-queries) and [Apollo Server](/apollo-server/performance/apq/).
One way to use persisted queries is with [apollo-link-persisted-queries](https://www.apollographql.com/docs/react/api/link/persisted-queries) and [Apollo Server](/apollo-server/performance/apq/).

## Custom fetching

Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/link/apollo-link-rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ An `@rest(…)` directive takes two required and several optional arguments:
| `pathBuilder?: /function/` | `string` | If provided, this function gets to control what path is produced for this request. |
| `bodyKey?: "input"` | `string` | This is the name of the `variable` to use when looking to build a REST request-body for a `PUT` or `POST` request. It defaults to `input` if not supplied. |
| `bodyBuilder?: /function/` | `string` | If provided, this is the name a `function` that you provided to `variables`, that is called when a request-body needs to be built. This lets you combine arguments or encode the body in some format other than JSON. |
| `bodySerializer?: /string | function/` | `string` | String key to look up a function in `bodySerializers` or a custom serialization function for the body/headers of this request before it is passed to the fetch call. Defaults to `JSON.stringify` and setting `Content-Type: application-json`. |
| `bodySerializer?: /string \| function/` | `string` | String key to look up a function in `bodySerializers` or a custom serialization function for the body/headers of this request before it is passed to the fetch call. Defaults to `JSON.stringify` and setting `Content-Type: application-json`. |

### Variables

Expand Down
7 changes: 3 additions & 4 deletions docs/source/api/link/apollo-link-ws.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ import { WebSocketLink } from "@apollo/client/link/ws";
import { SubscriptionClient } from "subscriptions-transport-ws";

const link = new WebSocketLink(
new SubscriptionClient({
uri: "ws://localhost:3000/subscriptions",
new SubscriptionClient("ws://localhost:4000/graphql", {
options: {
reconnect: true,
},
}),
});
})
);
```

### Options
Expand Down
2 changes: 1 addition & 1 deletion docs/source/caching/advanced-topics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const client = new ApolloClient({
}
}
}
}
})
});
```

Expand Down
37 changes: 37 additions & 0 deletions docs/source/caching/cache-field-behavior.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,43 @@ const cache = new InMemoryCache({
});
```

If a field requires numerous parameters then each parameter must be wrapped in a variable that is then destructured and returned.
Each parameter will be available as individual subfields.

The following `read` function assigns a default value of `UNKNOWN FIRST_NAME` to the `first_name` subfield of a `fullName` field and a `UNKNOWN LAST_NAME` to the `last_name` of a `fullName` field.

```ts
const cache = new InMemoryCache({
typePolicies: {
Person: {
fields: {
fullName: {
read(full_name = {
first_name: "UNKNOWN FIRST_NAME",
last_name: "UNKNOWN LAST_NAME",
}) {
return { ...full_name };
},
},
},
},
},
});
```

The following `query` returns the `first_name` and `last_name` subfields from the `fullName` field:

```graphql
query personWithFullName {
fullName {
first_name
last_name
}
}
```

If a field accepts arguments, the second parameter includes the values of those arguments. The following `read` function checks to see if the `maxLength` argument is provided when the `name` field is queried. If it is, the function returns only the first `maxLength` characters of the person's name. Otherwise, the person's full name is returned.

You can define a `read` function for a field that isn't even defined in your schema. For example, the following `read` function enables you to query a `userId` field that is always populated with locally stored data:

```ts
Expand Down
Loading

0 comments on commit 2e58f60

Please sign in to comment.