Repository: apollographql/apollo-client

Problem statement:
Circular dependencies
```
store.js -> optimistic-data/store.js -> store.js
core/ObservableQuery.js -> core/QueryManager.js -> scheduler/scheduler.js -> core/ObservableQuery.js
core/QueryManager.js -> scheduler/scheduler.js -> core/QueryManager.js
optimistic-data/store.js -> store.js -> optimistic-data/store.js
scheduler/scheduler.js -> core/QueryManager.js -> scheduler/scheduler.js
```

@DxCx 


Hints:

Patch:
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,15 @@
+function globals(mod) {
+  if (mod.indexOf('lodash/') === 0) return '_';
+}
+
+export default {
+  entry: 'lib/src/index.js',
+  dest: 'lib/apollo.umd.js',
+  format: 'umd',
+  sourceMap: true,
+  moduleName: 'apollo',
+  external: [
+    'lodash'
+  ],
+  globals
+};
diff --git a/src/ApolloClient.ts b/src/ApolloClient.ts
--- a/src/ApolloClient.ts
+++ b/src/ApolloClient.ts
@@ -13,8 +13,8 @@ import {
 
 } from 'graphql';
 
-import isUndefined = require('lodash/isUndefined');
-import isString = require('lodash/isString');
+import isUndefined from 'lodash/isUndefined';
+import isString from 'lodash/isString';
 
 import {
   createApolloStore,
@@ -30,10 +30,13 @@ import {
 
 import {
   QueryManager,
+} from './core/QueryManager';
+
+import {
   ApolloQueryResult,
   ResultComparator,
   ResultTransformer,
-} from './core/QueryManager';
+} from './core/types';
 
 import {
   ObservableQuery,
diff --git a/src/core/ObservableQuery.ts b/src/core/ObservableQuery.ts
--- a/src/core/ObservableQuery.ts
+++ b/src/core/ObservableQuery.ts
@@ -17,15 +17,18 @@ import {
 
 import {
   QueryManager,
+} from './QueryManager';
+
+import {
   ApolloQueryResult,
   FetchType,
-} from './QueryManager';
+} from './types';
 
 import { tryFunctionOrLogError } from '../util/errorHandling';
 
 import { NetworkStatus } from '../queries/store';
 
-import isEqual = require('lodash/isEqual');
+import isEqual from 'lodash/isEqual';
 
 export type ApolloCurrentResult = {
   data: any;
diff --git a/src/core/QueryManager.ts b/src/core/QueryManager.ts
--- a/src/core/QueryManager.ts
+++ b/src/core/QueryManager.ts
@@ -8,8 +8,22 @@ import {
   Deduplicator,
 } from '../transport/Deduplicator';
 
-import forOwn = require('lodash/forOwn');
-import isEqual = require('lodash/isEqual');
+import forOwn from 'lodash/forOwn';
+import isEqual from 'lodash/isEqual';
+
+import {
+  ResultTransformer,
+  ResultComparator,
+  QueryListener,
+  ApolloQueryResult,
+  FetchType,
+  SubscriptionOptions,
+} from './types';
+
+import {
+  QueryStoreValue,
+  NetworkStatus,
+} from '../queries/store';
 
 import {
   ApolloStore,
@@ -18,10 +32,6 @@ import {
   ApolloReducerConfig,
 } from '../store';
 
-import {
-  QueryStoreValue,
-} from '../queries/store';
-
 import {
   checkDocument,
   getQueryDefinition,
@@ -82,10 +92,6 @@ import {
   Observable,
 } from '../util/Observable';
 
-import {
-  NetworkStatus,
-} from '../queries/store';
-
 import { tryFunctionOrLogError } from '../util/errorHandling';
 
 import {
@@ -97,44 +103,6 @@ import { WatchQueryOptions } from './watchQueryOptions';
 
 import { ObservableQuery } from './ObservableQuery';
 
-export type QueryListener = (queryStoreValue: QueryStoreValue) => void;
-
-export interface SubscriptionOptions {
-  document: Document;
-  variables?: { [key: string]: any };
-};
-
-export type ApolloQueryResult = {
-  data: any;
-  loading: boolean;
-  networkStatus: NetworkStatus;
-
-  // This type is different from the GraphQLResult type because it doesn't include errors.
-  // Those are thrown via the standard promise/observer catch mechanism.
-};
-
-// A result transformer is given the data that is to be returned from the store from a query or
-// mutation, and can modify or observe it before the value is provided to your application.
-//
-// For watched queries, the transformer is only called when the data retrieved from the server is
-// different from previous.
-//
-// If the transformer wants to mutate results (say, by setting the prototype of result data), it
-// will likely need to be paired with a custom resultComparator.  By default, Apollo performs a
-// deep equality comparsion on results, and skips those that are considered equal - reducing
-// re-renders.
-export type ResultTransformer = (resultData: ApolloQueryResult) => ApolloQueryResult;
-
-// Controls how Apollo compares two query results and considers their equality.  Two equal results
-// will not trigger re-renders.
-export type ResultComparator = (result1: ApolloQueryResult, result2: ApolloQueryResult) => boolean;
-
-export enum FetchType {
-  normal = 1,
-  refetch = 2,
-  poll = 3,
-}
-
 export class QueryManager {
   public pollingTimers: {[queryId: string]: NodeJS.Timer | any}; //oddity in Typescript
   public scheduler: QueryScheduler;
@@ -598,7 +566,6 @@ export class QueryManager {
     this.fetchQueryPromises[requestId.toString()] = { promise, resolve, reject };
   }
 
-
   // Removes the promise in this.fetchQueryPromises for a particular request ID.
   public removeFetchQueryPromise(requestId: number) {
     delete this.fetchQueryPromises[requestId.toString()];
diff --git a/src/core/types.ts b/src/core/types.ts
new file mode 100644
--- /dev/null
+++ b/src/core/types.ts
@@ -0,0 +1,43 @@
+import { Document } from 'graphql';
+import {
+  QueryStoreValue,
+  NetworkStatus,
+} from '../queries/store';
+
+export interface SubscriptionOptions {
+  document: Document;
+  variables?: { [key: string]: any };
+};
+
+export type QueryListener = (queryStoreValue: QueryStoreValue) => void;
+
+export type ApolloQueryResult = {
+  data: any;
+  loading: boolean;
+  networkStatus: NetworkStatus;
+
+  // This type is different from the GraphQLResult type because it doesn't include errors.
+  // Those are thrown via the standard promise/observer catch mechanism.
+};
+
+// A result transformer is given the data that is to be returned from the store from a query or
+// mutation, and can modify or observe it before the value is provided to your application.
+//
+// For watched queries, the transformer is only called when the data retrieved from the server is
+// different from previous.
+//
+// If the transformer wants to mutate results (say, by setting the prototype of result data), it
+// will likely need to be paired with a custom resultComparator.  By default, Apollo performs a
+// deep equality comparsion on results, and skips those that are considered equal - reducing
+// re-renders.
+export type ResultTransformer = (resultData: ApolloQueryResult) => ApolloQueryResult;
+
+// Controls how Apollo compares two query results and considers their equality.  Two equal results
+// will not trigger re-renders.
+export type ResultComparator = (result1: ApolloQueryResult, result2: ApolloQueryResult) => boolean;
+
+export enum FetchType {
+  normal = 1,
+  refetch = 2,
+  poll = 3,
+}
diff --git a/src/data/debug.ts b/src/data/debug.ts
--- a/src/data/debug.ts
+++ b/src/data/debug.ts
@@ -1,7 +1,7 @@
 // For development only!
-import isObject = require('lodash/isObject');
-import omit = require('lodash/omit');
-import mapValues = require('lodash/mapValues');
+import isObject from 'lodash/isObject';
+import omit from 'lodash/omit';
+import mapValues from 'lodash/mapValues';
 
 export function stripLoc(obj: Object) {
   if (Array.isArray(obj)) {
diff --git a/src/data/mutationResults.ts b/src/data/mutationResults.ts
--- a/src/data/mutationResults.ts
+++ b/src/data/mutationResults.ts
@@ -8,8 +8,8 @@ import {
   GraphQLResult,
 } from 'graphql';
 
-import mapValues = require('lodash/mapValues');
-import cloneDeep = require('lodash/cloneDeep');
+import mapValues from 'lodash/mapValues';
+import cloneDeep from 'lodash/cloneDeep';
 
 import { replaceQueryResults } from './replaceQueryResults';
 
diff --git a/src/data/scopeQuery.ts b/src/data/scopeQuery.ts
--- a/src/data/scopeQuery.ts
+++ b/src/data/scopeQuery.ts
@@ -13,7 +13,7 @@ import {
   resultKeyNameFromField,
 } from './storeUtils';
 
-import isNumber = require('lodash/isNumber');
+import isNumber from 'lodash/isNumber';
 
 // The type of a path
 export type StorePath = (string|number)[];
diff --git a/src/data/storeUtils.ts b/src/data/storeUtils.ts
--- a/src/data/storeUtils.ts
+++ b/src/data/storeUtils.ts
@@ -15,7 +15,7 @@ import {
   Name,
 } from 'graphql';
 
-import isObject = require('lodash/isObject');
+import isObject from 'lodash/isObject';
 
 function isStringValue(value: Value): value is StringValue {
   return value.kind === 'StringValue';
diff --git a/src/data/writeToStore.ts b/src/data/writeToStore.ts
--- a/src/data/writeToStore.ts
+++ b/src/data/writeToStore.ts
@@ -1,6 +1,6 @@
-import isNull = require('lodash/isNull');
-import isUndefined = require('lodash/isUndefined');
-import isObject = require('lodash/isObject');
+import isNull from 'lodash/isNull';
+import isUndefined from 'lodash/isUndefined';
+import isObject from 'lodash/isObject';
 
 import {
   getOperationDefinition,
diff --git a/src/index.ts b/src/index.ts
--- a/src/index.ts
+++ b/src/index.ts
@@ -65,7 +65,7 @@ import ApolloClient from './ApolloClient';
 
 import {
   ApolloQueryResult,
-} from './core/QueryManager';
+} from './core/types';
 
 import {
   toIdValue,
diff --git a/src/optimistic-data/store.ts b/src/optimistic-data/store.ts
--- a/src/optimistic-data/store.ts
+++ b/src/optimistic-data/store.ts
@@ -14,11 +14,11 @@ import {
 } from '../data/storeUtils';
 
 import {
-  getDataWithOptimisticResults,
   Store,
 } from '../store';
 
-import pick = require('lodash/pick');
+import assign from 'lodash/assign';
+import pick from 'lodash/pick';
 
 // a stack of patches of new or changed documents
 export type OptimisticStore = {
@@ -28,6 +28,14 @@ export type OptimisticStore = {
 
 const optimisticDefaultState: any[] = [];
 
+export function getDataWithOptimisticResults(store: Store): NormalizedCache {
+  if (store.optimistic.length === 0) {
+    return store.data;
+  }
+  const patches = store.optimistic.map(opt => opt.data);
+  return assign({}, store.data, ...patches) as NormalizedCache;
+}
+
 export function optimistic(
   previousState = optimisticDefaultState,
   action: any,
@@ -49,7 +57,7 @@ export function optimistic(
     const fakeStore = {
       ...store,
       optimistic: previousState,
-    } as Store;
+    };
     const optimisticData = getDataWithOptimisticResults(fakeStore);
     const fakeDataResultState = data(
       optimisticData,
diff --git a/src/queries/getFromAST.ts b/src/queries/getFromAST.ts
--- a/src/queries/getFromAST.ts
+++ b/src/queries/getFromAST.ts
@@ -4,9 +4,9 @@ import {
   FragmentDefinition,
 } from 'graphql';
 
-import countBy = require('lodash/countBy');
-import identity = require('lodash/identity');
-import uniq = require('lodash/uniq');
+import countBy from 'lodash/countBy';
+import identity from 'lodash/identity';
+import uniq from 'lodash/uniq';
 
 export function getMutationDefinition(doc: Document): OperationDefinition {
   checkDocument(doc);
diff --git a/src/queries/queryTransform.ts b/src/queries/queryTransform.ts
--- a/src/queries/queryTransform.ts
+++ b/src/queries/queryTransform.ts
@@ -11,7 +11,7 @@ import {
   checkDocument,
 } from './getFromAST';
 
-import cloneDeep = require('lodash/cloneDeep');
+import cloneDeep from 'lodash/cloneDeep';
 
 const TYPENAME_FIELD: Field = {
   kind: 'Field',
diff --git a/src/queries/store.ts b/src/queries/store.ts
--- a/src/queries/store.ts
+++ b/src/queries/store.ts
@@ -18,7 +18,7 @@ import {
   GraphQLError,
 } from 'graphql';
 
-import isEqual = require('lodash/isEqual');
+import isEqual from 'lodash/isEqual';
 
 export interface QueryStore {
   [queryId: string]: QueryStoreValue;
diff --git a/src/scheduler/scheduler.ts b/src/scheduler/scheduler.ts
--- a/src/scheduler/scheduler.ts
+++ b/src/scheduler/scheduler.ts
@@ -10,10 +10,13 @@
 
 import {
   QueryManager,
-  QueryListener,
-  FetchType,
 } from '../core/QueryManager';
 
+import {
+  FetchType,
+  QueryListener,
+} from '../core/types';
+
 import { ObservableQuery } from '../core/ObservableQuery';
 
 import { WatchQueryOptions } from '../core/watchQueryOptions';
diff --git a/src/store.ts b/src/store.ts
--- a/src/store.ts
+++ b/src/store.ts
@@ -27,7 +27,9 @@ import {
 import {
   optimistic,
   OptimisticStore,
+  getDataWithOptimisticResults,
 } from './optimistic-data/store';
+export { getDataWithOptimisticResults };
 
 import {
   ApolloAction,
@@ -45,7 +47,7 @@ import {
   CustomResolverMap,
 } from './data/readFromStore';
 
-import assign = require('lodash/assign');
+import assign from 'lodash/assign';
 
 export interface Store {
   data: NormalizedCache;
@@ -184,17 +186,8 @@ export function createApolloStore({
   );
 }
 
-
 export type ApolloReducerConfig = {
   dataIdFromObject?: IdGetter;
   mutationBehaviorReducers?: MutationBehaviorReducerMap;
   customResolvers?: CustomResolverMap;
 };
-
-export function getDataWithOptimisticResults(store: Store): NormalizedCache {
-  if (store.optimistic.length === 0) {
-    return store.data;
-  }
-  const patches = store.optimistic.map(opt => opt.data);
-  return assign({}, store.data, ...patches) as NormalizedCache;
-}
diff --git a/src/transport/batchedNetworkInterface.ts b/src/transport/batchedNetworkInterface.ts
--- a/src/transport/batchedNetworkInterface.ts
+++ b/src/transport/batchedNetworkInterface.ts
@@ -4,8 +4,8 @@ import {
 
 import 'whatwg-fetch';
 
-import assign = require('lodash/assign');
-import isNumber = require('lodash/isNumber');
+import assign from 'lodash/assign';
+import isNumber from 'lodash/isNumber';
 
 import {
   HTTPFetchNetworkInterface,
diff --git a/src/transport/networkInterface.ts b/src/transport/networkInterface.ts
--- a/src/transport/networkInterface.ts
+++ b/src/transport/networkInterface.ts
@@ -1,6 +1,7 @@
-import isString = require('lodash/isString');
-import assign = require('lodash/assign');
-import mapValues = require('lodash/mapValues');
+import isString from 'lodash/isString';
+import assign from 'lodash/assign';
+import mapValues from 'lodash/mapValues';
+
 import 'whatwg-fetch';
 
 import {


Test patch:
diff --git a/test/QueryManager.ts b/test/QueryManager.ts
--- a/test/QueryManager.ts
+++ b/test/QueryManager.ts
@@ -36,13 +36,13 @@ import ApolloClient, {
 
 import {
   ApolloQueryResult,
-} from '../src/core/QueryManager';
+} from '../src/core/types';
 
 import { createStore, combineReducers, applyMiddleware } from 'redux';
 
 import * as Rx from 'rxjs';
 
-import assign = require('lodash/assign');
+import { assign } from 'lodash';
 
 import mockNetworkInterface, {
   ParsedRequest,
diff --git a/test/batchedNetworkInterface.ts b/test/batchedNetworkInterface.ts
--- a/test/batchedNetworkInterface.ts
+++ b/test/batchedNetworkInterface.ts
@@ -1,6 +1,6 @@
 import { assert } from 'chai';
 
-import merge = require('lodash/merge');
+import { merge } from 'lodash';
 
 import { HTTPBatchedNetworkInterface } from '../src/transport/batchedNetworkInterface';
 
diff --git a/test/client.ts b/test/client.ts
--- a/test/client.ts
+++ b/test/client.ts
@@ -66,7 +66,7 @@ import {
   createMockedIResponse,
 } from './mocks/mockFetch';
 
-import * as chaiAsPromised from 'chai-as-promised';
+import chaiAsPromised from 'chai-as-promised';
 
 import { ApolloError } from '../src/errors/ApolloError';
 
@@ -74,9 +74,7 @@ import { withWarning } from './util/wrap';
 
 import observableToPromise from './util/observableToPromise';
 
-import cloneDeep = require('lodash/cloneDeep');
-
-import assign = require('lodash/assign');
+import { cloneDeep, assign } from 'lodash';
 
 // make it easy to assert with promises
 chai.use(chaiAsPromised);
diff --git a/test/directives.ts b/test/directives.ts
--- a/test/directives.ts
+++ b/test/directives.ts
@@ -11,7 +11,7 @@ import {
 
 import gql from 'graphql-tag';
 
-import cloneDeep = require('lodash/cloneDeep');
+import { cloneDeep } from 'lodash';
 
 describe('query directives', () => {
   it('should should not include a skipped field', () => {
diff --git a/test/fetchMore.ts b/test/fetchMore.ts
--- a/test/fetchMore.ts
+++ b/test/fetchMore.ts
@@ -5,8 +5,7 @@ import mockNetworkInterface from './mocks/mockNetworkInterface';
 import ApolloClient from '../src';
 import { ObservableQuery } from '../src/core/ObservableQuery';
 
-import assign = require('lodash/assign');
-import clonedeep = require('lodash/cloneDeep');
+import { assign, cloneDeep } from 'lodash';
 
 import gql from 'graphql-tag';
 
@@ -57,7 +56,7 @@ describe('updateQuery on a simple query', () => {
       .then((watchedQuery: ObservableQuery) => {
         assert.equal(latestResult.data.entry.value, 1);
         watchedQuery.updateQuery((prevResult: any) => {
-          const res = clonedeep(prevResult);
+          const res = cloneDeep(prevResult);
           res.entry.value = 2;
           return res;
         });
@@ -109,7 +108,7 @@ describe('fetchMore on an observable query', () => {
       },
     },
   };
-  const resultMore = clonedeep(result);
+  const resultMore = cloneDeep(result);
   const result2: any = {
     data: {
       __typename: 'Query',
@@ -175,7 +174,7 @@ describe('fetchMore on an observable query', () => {
       return watchedQuery.fetchMore({
         variables: { start: 10 }, // rely on the fact that the original variables had limit: 10
         updateQuery: (prev, options) => {
-          const state = clonedeep(prev) as any;
+          const state = cloneDeep(prev) as any;
           state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).data.entry.comments];
           return state;
         },
@@ -205,7 +204,7 @@ describe('fetchMore on an observable query', () => {
         query: query2,
         variables: variables2,
         updateQuery: (prev, options) => {
-          const state = clonedeep(prev) as any;
+          const state = cloneDeep(prev) as any;
           state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).data.comments];
           return state;
         },
diff --git a/test/fixtures/redux-todomvc/reducers.ts b/test/fixtures/redux-todomvc/reducers.ts
--- a/test/fixtures/redux-todomvc/reducers.ts
+++ b/test/fixtures/redux-todomvc/reducers.ts
@@ -1,5 +1,5 @@
 import { combineReducers } from 'redux';
-import assign = require('lodash/assign');
+import { assign } from 'lodash';
 
 import {
   ADD_TODO,
diff --git a/test/graphqlSubscriptions.ts b/test/graphqlSubscriptions.ts
--- a/test/graphqlSubscriptions.ts
+++ b/test/graphqlSubscriptions.ts
@@ -6,7 +6,7 @@ import {
   assert,
 } from 'chai';
 
-import clonedeep = require('lodash/cloneDeep');
+import { cloneDeep } from 'lodash';
 
 import { isSubscriptionResultAction } from '../src/actions';
 
@@ -282,7 +282,7 @@ describe('GraphQL Subscriptions', () => {
       reducer: (previousResult, action) => {
         counter++;
         if (isSubscriptionResultAction(action)) {
-          const newResult = clonedeep(previousResult) as any;
+          const newResult = cloneDeep(previousResult) as any;
           newResult.number++;
           return newResult;
         }
diff --git a/test/mockNetworkInterface.ts b/test/mockNetworkInterface.ts
--- a/test/mockNetworkInterface.ts
+++ b/test/mockNetworkInterface.ts
@@ -7,7 +7,7 @@ import {
   MockedSubscription,
 } from './mocks/mockNetworkInterface';
 
-import omit = require('lodash/omit');
+import { omit } from 'lodash';
 
 import gql from 'graphql-tag';
 
diff --git a/test/mutationResults.ts b/test/mutationResults.ts
--- a/test/mutationResults.ts
+++ b/test/mutationResults.ts
@@ -7,8 +7,7 @@ import { isMutationResultAction, isQueryResultAction } from '../src/actions';
 
 import { Subscription } from '../src/util/Observable';
 
-import assign = require('lodash/assign');
-import clonedeep = require('lodash/cloneDeep');
+import { assign, cloneDeep } from 'lodash';
 
 import { ObservableQuery } from '../src/core/ObservableQuery';
 
@@ -743,7 +742,7 @@ describe('mutation results', () => {
           reducer: (previousResult, action) => {
             counter++;
             if (isMutationResultAction(action)) {
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.todos.unshift(action.result.data.createTodo);
               return newResult;
             }
@@ -799,7 +798,7 @@ describe('mutation results', () => {
           reducer: (previousResult, action, variables: any) => {
             counter++;
             if (isMutationResultAction(action) && variables['id'] === 5) {
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.todos.unshift(action.result.data.createTodo);
               return newResult;
             }
@@ -854,7 +853,7 @@ describe('mutation results', () => {
           reducer: (previousResult, action) => {
             if (isMutationResultAction(action) && action.operationName === 'createTodo') {
               counter++;
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.todos.unshift(action.result.data.createTodo);
               return newResult;
             }
@@ -871,7 +870,7 @@ describe('mutation results', () => {
           reducer: (previousResult, action) => {
             if (isMutationResultAction(action) && action.operationName === 'wrongName') {
               counter++; // shouldn't be called, so counter shouldn't increase.
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.todos.unshift(action.result.data.createTodo);
               return newResult;
             }
@@ -919,7 +918,7 @@ describe('mutation results', () => {
           reducer: (previousResult, action) => {
             counter++;
             if (isQueryResultAction(action)) {
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.todos.unshift(action.result.data.newTodos[0]);
               return newResult;
             }
@@ -1003,7 +1002,7 @@ describe('mutation results', () => {
           reducer: (previousResult, action) => {
             counter++;
             if (isMutationResultAction(action)) {
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.todos.unshift(action.result.data.createTodo);
               return newResult;
             }
@@ -1018,7 +1017,7 @@ describe('mutation results', () => {
           reducer: (previousResult, action) => {
             counter2++;
             if (isMutationResultAction(action) && action.result.data.createTodo.completed) {
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.filteredTodos.unshift(action.result.data.createTodo);
               return newResult;
             }
@@ -1170,7 +1169,7 @@ describe('mutation results', () => {
               assert.equal(mResult.data.createTodo.id, '99');
               assert.equal(mResult.data.createTodo.text, 'This one was created with a mutation.');
 
-              const state = clonedeep(prev) as any;
+              const state = cloneDeep(prev) as any;
               state.todoList.todos.unshift(mResult.data.createTodo);
               return state;
             },
@@ -1209,7 +1208,7 @@ describe('mutation results', () => {
             assert.equal(mResult.data.createTodo.id, '99');
             assert.equal(mResult.data.createTodo.text, 'This one was created with a mutation.');
 
-            const state = clonedeep(prev) as any;
+            const state = cloneDeep(prev) as any;
             state.todoList.todos.unshift(mResult.data.createTodo);
             return state;
           },
@@ -1233,7 +1232,7 @@ describe('mutation results', () => {
             updateQueries: {
               todoList: (prev, options) => {
                 const mResult = options.mutationResult as any;
-                const state = clonedeep(prev) as any;
+                const state = cloneDeep(prev) as any;
                 // It's unfortunate that this function is called at all, but we are removing
                 // the updateQueries API soon so it won't matter.
                 state.todoList.todos.unshift(mResult.data && mResult.data.createTodo);
@@ -1248,7 +1247,7 @@ describe('mutation results', () => {
               updateQueries: {
                 todoList: (prev, options) => {
                   const mResult = options.mutationResult as any;
-                  const state = clonedeep(prev) as any;
+                  const state = cloneDeep(prev) as any;
                   state.todoList.todos.unshift(mResult.data.createTodo);
                   return state;
                 },
diff --git a/test/networkInterface.ts b/test/networkInterface.ts
--- a/test/networkInterface.ts
+++ b/test/networkInterface.ts
@@ -1,9 +1,8 @@
 import * as chai from 'chai';
-import * as chaiAsPromised from 'chai-as-promised';
+import chaiAsPromised from 'chai-as-promised';
 
-import assign = require('lodash/assign');
-import isequal = require('lodash/isEqual');
-import * as fetchMock from 'fetch-mock';
+import { assign, isEqual } from 'lodash';
+import fetchMock from 'fetch-mock';
 
 // make it easy to assert with promises
 chai.use(chaiAsPromised);
@@ -116,12 +115,12 @@ describe('network interface', () => {
       }
 
       if (query === print(simpleQueryWithVar)
-          && isequal(variables, { personNum: 1 })) {
+          && isEqual(variables, { personNum: 1 })) {
         return simpleResult;
       }
 
       if (query === print(complexQueryWithTwoVars)
-          && isequal(variables, { personNum: 1, filmNum: 1 })) {
+          && isEqual(variables, { personNum: 1, filmNum: 1 })) {
         return complexResult;
       }
 
diff --git a/test/optimistic.ts b/test/optimistic.ts
--- a/test/optimistic.ts
+++ b/test/optimistic.ts
@@ -6,8 +6,7 @@ import ApolloClient from '../src';
 import { MutationBehaviorReducerArgs, MutationBehavior, MutationQueryReducersMap } from '../src/data/mutationResults';
 import { NormalizedCache, StoreObject } from '../src/data/storeUtils';
 
-import assign = require('lodash/assign');
-import clonedeep = require('lodash/cloneDeep');
+import { assign, cloneDeep} from 'lodash';
 
 import { Subscription } from '../src/util/Observable';
 
@@ -721,7 +720,7 @@ describe('optimistic mutation results', () => {
               const mResult = options.mutationResult as any;
               assert.equal(mResult.data.createTodo.id, '99');
 
-              const state = clonedeep(prev) as any;
+              const state = cloneDeep(prev) as any;
               state.todoList.todos.unshift(mResult.data.createTodo);
               return state;
             },
@@ -771,7 +770,7 @@ describe('optimistic mutation results', () => {
           todoList: (prev, options) => {
             const mResult = options.mutationResult as any;
 
-            const state = clonedeep(prev) as any;
+            const state = cloneDeep(prev) as any;
             state.todoList.todos.unshift(mResult.data.createTodo);
             return state;
           },
@@ -845,7 +844,7 @@ describe('optimistic mutation results', () => {
           todoList: (prev, options) => {
             const mResult = options.mutationResult as any;
 
-            const state = clonedeep(prev) as any;
+            const state = cloneDeep(prev) as any;
             state.todoList.todos.unshift(mResult.data.createTodo);
             return state;
           },
@@ -950,7 +949,7 @@ describe('optimistic mutation results', () => {
           reducer: (previousResult, action) => {
             counter++;
             if (isMutationResultAction(action)) {
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.todos.unshift(action.result.data.createTodo);
               return newResult;
             }
@@ -978,7 +977,7 @@ describe('optimistic mutation results', () => {
           reducer: (previousResult, action) => {
             counter++;
             if (isMutationResultAction(action)) {
-              const newResult = clonedeep(previousResult) as any;
+              const newResult = cloneDeep(previousResult) as any;
               newResult.todoList.todos.unshift(action.result.data.createTodo);
               return newResult;
             }
@@ -1134,7 +1133,7 @@ describe('optimistic mutation - githunt comments', () => {
   const updateQueries = {
     Comment: (prev, { mutationResult: mutationResultArg }) => {
       const newComment = (mutationResultArg as any).data.submitComment;
-      const state = clonedeep(prev);
+      const state = cloneDeep(prev);
       (state as any).entry.comments.unshift(newComment);
       return state;
     },
diff --git a/test/readFromStore.ts b/test/readFromStore.ts
--- a/test/readFromStore.ts
+++ b/test/readFromStore.ts
@@ -1,6 +1,5 @@
 import { assert } from 'chai';
-import assign = require('lodash/assign');
-import omit = require('lodash/omit');
+import { assign, omit } from 'lodash';
 
 import {
   readQueryFromStore,
diff --git a/test/subscribeToMore.ts b/test/subscribeToMore.ts
--- a/test/subscribeToMore.ts
+++ b/test/subscribeToMore.ts
@@ -4,10 +4,8 @@ const { assert } = chai;
 import {
   mockSubscriptionNetworkInterface,
 } from './mocks/mockNetworkInterface';
-import ApolloClient from '../src';
 
-// import assign = require('lodash/assign');
-// import clonedeep = require('lodash/cloneDeep');
+import ApolloClient from '../src';
 
 import gql from 'graphql-tag';
 
diff --git a/test/util/observableToPromise.ts b/test/util/observableToPromise.ts
--- a/test/util/observableToPromise.ts
+++ b/test/util/observableToPromise.ts
@@ -1,5 +1,5 @@
 import { ObservableQuery } from '../../src/core/ObservableQuery';
-import { ApolloQueryResult } from '../../src/core/QueryManager';
+import { ApolloQueryResult } from '../../src/core/types';
 import { Subscription } from '../../src/util/Observable';
 
 /**
diff --git a/test/util/subscribeAndCount.ts b/test/util/subscribeAndCount.ts
--- a/test/util/subscribeAndCount.ts
+++ b/test/util/subscribeAndCount.ts
@@ -1,5 +1,5 @@
 import { ObservableQuery } from '../../src/core/ObservableQuery';
-import { ApolloQueryResult } from '../../src/core/QueryManager';
+import { ApolloQueryResult } from '../../src/core/types';
 import { Subscription } from '../../src/util/Observable';
 
 import wrap from './wrap';
diff --git a/test/writeToStore.ts b/test/writeToStore.ts
--- a/test/writeToStore.ts
+++ b/test/writeToStore.ts
@@ -1,7 +1,5 @@
 import { assert } from 'chai';
-import cloneDeep = require('lodash/cloneDeep');
-import assign = require('lodash/assign');
-import omit = require('lodash/omit');
+import { cloneDeep, assign, omit } from 'lodash';
 
 import {
   writeQueryToStore,