Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit e4a5b68

Browse files
authored
Merge pull request #2825 from apollographql/hwillson/allow-mocked-resolvers
Allow resolvers to be passed into `MockedProvider` and set a default
2 parents 7801b79 + f1b1103 commit e4a5b68

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change log
22

3+
## 2.5.1
4+
5+
### Bug Fixes
6+
7+
- Make sure `MockedProvider` enables Apollo Client 2.5's local state handling,
8+
and allow custom / mocked resolvers to be passed in as props, and used with
9+
the created test `ApolloClient` instance. <br/>
10+
[@hwillson](https://github.com/hwillson) in [#2825](https://github.com/apollographql/react-apollo/pull/2825)
11+
12+
313
## 2.5.0
414

515
### Improvements

src/test-utils.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import ApolloClient from 'apollo-client';
3-
import { DefaultOptions } from 'apollo-client';
3+
import { DefaultOptions, Resolvers } from 'apollo-client';
44
import { InMemoryCache as Cache } from 'apollo-cache-inmemory';
55

66
import { ApolloProvider } from './index';
@@ -13,6 +13,7 @@ export interface MockedProviderProps<TSerializedCache = {}> {
1313
addTypename?: boolean;
1414
defaultOptions?: DefaultOptions;
1515
cache?: ApolloCache<TSerializedCache>;
16+
resolvers?: Resolvers;
1617
}
1718

1819
export interface MockedProviderState {
@@ -27,11 +28,18 @@ export class MockedProvider extends React.Component<MockedProviderProps, MockedP
2728
constructor(props: MockedProviderProps) {
2829
super(props);
2930

30-
const { mocks, addTypename, defaultOptions, cache } = this.props;
31+
const {
32+
mocks,
33+
addTypename,
34+
defaultOptions,
35+
cache,
36+
resolvers = {},
37+
} = this.props;
3138
const client = new ApolloClient({
3239
cache: cache || new Cache({ addTypename }),
3340
defaultOptions,
3441
link: new MockLink(mocks || [], addTypename),
42+
resolvers,
3543
});
3644

3745
this.state = { client };

0 commit comments

Comments
 (0)