From 6632862baa9791cc4bc9f8d543c86d80aaff3655 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Wed, 27 Feb 2019 08:35:59 -0500 Subject: [PATCH 1/2] Allow resolvers to be passed into `MockedProvider` and set a default After the changes in https://github.com/apollographql/apollo-client/pull/4499, when `MockedProvider` is currently used it doesn't have any `resolvers` set. This means `@client` directives are passed into the link chain. Since we don't currently allow people to modify the link chain that `MockedProvider` uses, it's safe to assume people won't want this behaviour, as they can't test things like `apollo-link-state` this way. This commit sets a default `resolvers` value of `{}` to enable AC 2.5's new local state handling, and opens the door for passing custom resolvers into the `MockedProvider` via props. Helps fix https://github.com/apollographql/fullstack-tutorial/pull/73. --- src/test-utils.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test-utils.tsx b/src/test-utils.tsx index 53df07d48e..3cfc95f613 100644 --- a/src/test-utils.tsx +++ b/src/test-utils.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import ApolloClient from 'apollo-client'; -import { DefaultOptions } from 'apollo-client'; +import { DefaultOptions, Resolvers } from 'apollo-client'; import { InMemoryCache as Cache } from 'apollo-cache-inmemory'; import { ApolloProvider } from './index'; @@ -13,6 +13,7 @@ export interface MockedProviderProps { addTypename?: boolean; defaultOptions?: DefaultOptions; cache?: ApolloCache; + resolvers?: Resolvers; } export interface MockedProviderState { @@ -27,11 +28,18 @@ export class MockedProvider extends React.Component Date: Wed, 27 Feb 2019 08:41:58 -0500 Subject: [PATCH 2/2] Changelog update --- Changelog.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Changelog.md b/Changelog.md index 641ddcbe95..879fb15967 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,15 @@ # Change log +## 2.5.1 + +### Bug Fixes + +- Make sure `MockedProvider` enables Apollo Client 2.5's local state handling, + and allow custom / mocked resolvers to be passed in as props, and used with + the created test `ApolloClient` instance.
+ [@hwillson](https://github.com/hwillson) in [#2825](https://github.com/apollographql/react-apollo/pull/2825) + + ## 2.5.0 ### Improvements