Skip to content

Commit

Permalink
Merge branch 'master' into fix-mocksubscriptionlink-multiple-subscrip…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
dfrankland authored May 8, 2020
2 parents d4bed05 + c2698e5 commit 4617da1
Show file tree
Hide file tree
Showing 63 changed files with 2,357 additions and 3,334 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
- **[BREAKING]** `ApolloError`'s thrown by Apollo Client no longer prefix error messages with `GraphQL error:` or `Network error:`. To differentiate between GraphQL/network errors, refer to `ApolloError`'s public `graphQLErrors` and `networkError` properties. <br/>
[@lorensr](https://github.com/lorensr) in [#3892](https://github.com/apollographql/apollo-client/pull/3892)

- **[BREAKING]** Support for the `@live` directive has been removed, but might be restored in the future if a more thorough implementation is proposed. <br/>
[@benjamn](https://github.com/benjamn) in [#6221](https://github.com/apollographql/apollo-client/pull/6221)

- **[BREAKING?]** Refactor `QueryManager` to make better use of observables and enforce `fetchPolicy` more reliably. <br/>
[@benjamn](https://github.com/benjamn) in [#6221](https://github.com/apollographql/apollo-client/pull/6221)

- `InMemoryCache` now supports tracing garbage collection and eviction. Note that the signature of the `evict` method has been simplified in a potentially backwards-incompatible way. <br/>
[@benjamn](https://github.com/benjamn) in [#5310](https://github.com/apollographql/apollo-client/pull/5310)

Expand Down
2 changes: 1 addition & 1 deletion config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
},
globals: {
'ts-jest': {
diagnostics: false,
diagnostics: true,
},
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/link/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const logTimeLink = new ApolloLink((operation, forward) => {
const link = timeStartLink.concat(logTimeLink)
```

This example shows defines links, `timeStartLink` and `logTimeLink`. The `timeStartLink` assigns the current time to the context's `start` field. When the operation completes, the `logTimeLink` then subtracts the value of `start` from the current time to determine the total duration of the operation.
This example defines two links, `timeStartLink` and `logTimeLink`. The `timeStartLink` assigns the current time to the context's `start` field. When the operation completes, the `logTimeLink` then subtracts the value of `start` from the current time to determine the total duration of the operation.

The context's initial value can be set by Apollo Client before the link chain begins its execution. In this example, a call to `client.query` adds a `saveOffline` field to the context, which is then read by the custom link defined at the top:

Expand Down
1 change: 1 addition & 0 deletions docs/source/networking/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Another common way to identify yourself when using HTTP is to send along an auth

```js
import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client';
import { setContext } from '@apollo/link-context';

const httpLink = createHttpLink({
uri: '/graphql',
Expand Down
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apollo/client",
"version": "3.0.0-beta.44",
"version": "3.0.0-beta.46",
"description": "A fully-featured caching GraphQL client.",
"private": true,
"keywords": [
Expand Down Expand Up @@ -77,6 +77,7 @@
"devDependencies": {
"@testing-library/react": "9.4.1",
"@types/fast-json-stable-stringify": "2.0.0",
"@types/fetch-mock": "^7.3.2",
"@types/jest": "24.0.25",
"@types/lodash": "4.14.149",
"@types/node": "12.12.36",
Expand Down
30 changes: 16 additions & 14 deletions src/__tests__/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('ApolloClient', () => {

beforeEach(() => {
oldFetch = window.fetch;
window.fetch = () => null;
window.fetch = () => null as any;
})

afterEach(() => {
Expand Down Expand Up @@ -1175,7 +1175,6 @@ describe('ApolloClient', () => {
if (result.id && result.__typename) {
return result.__typename + result.id;
}
return null;
},
addTypename: true,
}),
Expand All @@ -1202,7 +1201,7 @@ describe('ApolloClient', () => {
expect(stripSymbols(readData)).toEqual(data);

// modify readData and writeQuery
const bestFriends = readData.people.friends.filter(
const bestFriends = readData!.people.friends.filter(
x => x.type === 'best',
);
// this should re call next
Expand Down Expand Up @@ -1254,7 +1253,7 @@ describe('ApolloClient', () => {
expect(stripSymbols(readData)).toEqual(data);

// modify readData and writeQuery
const friends = readData.people.friends;
const friends = readData!.people.friends;
friends[0].type = 'okayest';
friends[1].type = 'okayest';

Expand Down Expand Up @@ -1290,13 +1289,13 @@ describe('ApolloClient', () => {
type: 'okayest',
};
const nextFriends = stripSymbols(
nextResult.data.people.friends,
nextResult.data!.people.friends,
);
expect(nextFriends[0]).toEqual(expectation0);
expect(nextFriends[1]).toEqual(expectation1);

const readFriends = stripSymbols(
client.readQuery<Data>({ query }).people.friends,
client.readQuery<Data>({ query })!.people.friends,
);
expect(readFriends[0]).toEqual(expectation0);
expect(readFriends[1]).toEqual(expectation1);
Expand All @@ -1319,12 +1318,12 @@ describe('ApolloClient', () => {
expect(stripSymbols(observable.getCurrentResult().data)).toEqual(
data,
);
const bestFriends = result.data.people.friends.filter(
const bestFriends = result.data!.people.friends.filter(
x => x.type === 'best',
);
// this should re call next
client.writeFragment({
id: `Person${result.data.people.id}`,
id: `Person${result.data!.people.id}`,
fragment: gql`
fragment bestFriends on Person {
friends {
Expand All @@ -1349,7 +1348,7 @@ describe('ApolloClient', () => {
}

if (count === 2) {
expect(stripSymbols(result.data.people.friends)).toEqual([
expect(stripSymbols(result.data!.people.friends)).toEqual([
bestFriend,
]);
done();
Expand All @@ -1370,11 +1369,11 @@ describe('ApolloClient', () => {
expect(stripSymbols(observable.getCurrentResult().data)).toEqual(
data,
);
const friends = result.data.people.friends;
const friends = result.data!.people.friends;

// this should re call next
client.writeFragment({
id: `Person${result.data.people.id}`,
id: `Person${result.data!.people.id}`,
fragment: gql`
fragment bestFriends on Person {
friends {
Expand Down Expand Up @@ -1403,7 +1402,7 @@ describe('ApolloClient', () => {
}

if (count === 2) {
const nextFriends = stripSymbols(result.data.people.friends);
const nextFriends = stripSymbols(result.data!.people.friends);
expect(nextFriends[0]).toEqual({
...bestFriend,
type: 'okayest',
Expand Down Expand Up @@ -2216,8 +2215,11 @@ describe('ApolloClient', () => {
}
`,
};
const _query = client.queryManager!.query;
client.queryManager!.query = options => {

// @ts-ignore
const queryManager = client.queryManager;
const _query = queryManager.query;
queryManager.query = options => {
queryOptions = options;
return _query(options);
};
Expand Down
Loading

0 comments on commit 4617da1

Please sign in to comment.