diff --git a/src/ApolloProvider.tsx b/src/ApolloProvider.tsx index 06a7f78f7f..c3f2403bc7 100644 --- a/src/ApolloProvider.tsx +++ b/src/ApolloProvider.tsx @@ -16,6 +16,8 @@ import { import ApolloClient from 'apollo-client'; +import invariant = require('invariant'); + export declare interface ProviderProps { store?: Store; client: ApolloClient; @@ -42,6 +44,13 @@ export default class ApolloProvider extends Component { constructor(props, context) { super(props, context); + + invariant( + props.client, + 'ApolloClient was not passed a client instance. Make ' + + 'sure you pass in your client via the "client" prop.' + ); + this.client = props.client; if (props.store) { diff --git a/test/client/ApolloProvider.tsx b/test/client/ApolloProvider.tsx index b04c3b9076..b79291678b 100644 --- a/test/client/ApolloProvider.tsx +++ b/test/client/ApolloProvider.tsx @@ -49,6 +49,19 @@ describe(' Component', () => { expect(wrapper.contains(
)).to.equal(true); }); + it('should require a client', () => { + expect(() => { + shallow( + +
+ + ) + }).to.throw( + 'ApolloClient was not passed a client instance. Make ' + + 'sure you pass in your client via the "client" prop.' + ); + }) + it('should not require a store', () => { const wrapper = shallow(