diff --git a/Changelog.md b/Changelog.md index 56c4d746e1..9b32175619 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,7 +10,8 @@ first three params (`TChildProps` can be derived). [#1402](https://github.com/ap - Remove deprecated `operationOptions.options.skip`, use `operationOptions.skip` instead - Rename type `ProviderProps` to `ApolloProviderProps` [#1467](https://github.com/apollographql/react-apollo/pull/1467) - Rename `getDataFromTree` type `QueryResult` to `QueryTreeResult` [#1467](https://github.com/apollographql/react-apollo/pull/1467) - - Rename type `QueryProps` to `GraphqlQueryControls` [#1467](https://github.com/apollographql/react-apollo/pull/1467) + - Rename type `QueryProps` to `GraphqlQueryControls` [#1467](https://github.com/apollographql/react-apollo/pull/1467) [#1478](https://github.com/apollographql/react-apollo/pull/1478) + - Remove re-export of `compose` (a.k.a. `lodash/flowright`) as it is loses types (exports as `any`). Users may choose to use `lodash/flowright` or `recompose/compose` themselves based on their use case. [#1478](https://github.com/apollographql/react-apollo/pull/1478) - **Other Changes** - Update all dependencies, scripts' usage, prettier and typescript setup [#1402](https://github.com/apollographql/react-apollo/pull/1402) diff --git a/package.json b/package.json index b75af51eaf..b3ace440e6 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "bundlesize": [ { "path": "./lib/umd/react-apollo.js", - "threshold": "1 Kb" + "maxSize": "4.7 KB" } ], "lint-staged": { @@ -54,17 +54,15 @@ "preset": "react-native", "testEnvironment": "jsdom", "transform": { - "^.+\\.tsx?$": "/node_modules/ts-jest/preprocessor.js", + "^.+\\.tsx?$": "ts-jest", "^.+\\.jsx?$": "babel-jest" }, - "transformIgnorePatterns": [ - "/node_modules/(?!(lodash-es|react-native)/)" - ], + "transformIgnorePatterns": ["/node_modules/(?!(react-native)/)"], "mapCoverage": true, "moduleFileExtensions": ["ts", "tsx", "js", "json"], "modulePathIgnorePatterns": [ "/examples", - "/test/flow.js", + "/test/flow-usage.js", "/test/typescript-usage.tsx" ], "projects": [""], @@ -103,7 +101,6 @@ "jest": "21.2.1", "jsdom": "11.5.1", "lint-staged": "6.0.0", - "lodash": "4.17.4", "pre-commit": "1.2.2", "prettier": "1.9.2", "react": "16.2.0", @@ -125,8 +122,7 @@ "fbjs": "^0.8.16", "hoist-non-react-statics": "^2.3.1", "invariant": "^2.2.2", - "lodash.flowright": "^3.5.0", - "lodash.pick": "^4.4.0", + "lodash": "4.17.4", "prop-types": "^15.6.0" } } diff --git a/src/Query.tsx b/src/Query.tsx index e690551db3..13cb3a34fa 100644 --- a/src/Query.tsx +++ b/src/Query.tsx @@ -17,7 +17,7 @@ import { parser, DocumentType } from './parser'; const shallowEqual = require('fbjs/lib/shallowEqual'); const invariant = require('invariant'); -const pick = require('lodash.pick'); +const pick = require('lodash/pick'); function observableQueryFields(observable) { const fields = pick( diff --git a/src/graphql.tsx b/src/graphql.tsx index 9bc9df12b2..53996b2b3e 100644 --- a/src/graphql.tsx +++ b/src/graphql.tsx @@ -20,7 +20,7 @@ import { const shallowEqual = require('fbjs/lib/shallowEqual'); const invariant = require('invariant'); const assign = require('object-assign'); -const pick = require('lodash.pick'); +const pick = require('lodash/pick'); const hoistNonReactStatics = require('hoist-non-react-statics'); const defaultMapPropsToOptions = () => ({}); diff --git a/src/index.js.flow b/src/index.js.flow index d38073822e..d48fcc62c2 100644 --- a/src/index.js.flow +++ b/src/index.js.flow @@ -14,11 +14,10 @@ import type { } from 'apollo-client'; import type { DocumentNode, VariableDefinitionNode } from 'graphql'; import gql from 'graphql-tag'; -import compose from 'lodash.flowright'; // export everything from apollo-client export * from 'apollo-client'; -export { gql, compose }; +export { gql }; export interface ProviderProps { client: ApolloClient; @@ -42,7 +41,7 @@ export type MutationFunc = ( ) => Promise>; export type ChildProps = { - data: QueryProps & R, + data: GraphqlQueryControls & R, mutate: MutationFunc, } & P; @@ -65,7 +64,7 @@ export interface QueryOpts { skip?: boolean; } -export interface QueryProps { +export interface GraphqlQueryControls { error?: ApolloError; networkStatus: number; loading: boolean; @@ -84,7 +83,7 @@ export interface QueryProps { export interface OptionProps { ownProps: TProps; - data: QueryProps & TResult; + data: GraphqlQueryControls & TResult; mutate: MutationFunc; } diff --git a/src/index.ts b/src/index.ts index 8bb83ee236..b02a40032f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,3 @@ export * from './graphql'; export { default as withApollo } from './withApollo'; export * from './types'; - -// expose easy way to join queries from redux -import * as compose from 'lodash.flowright'; -export { compose }; diff --git a/test/client/graphql/mutations/queries.test.tsx b/test/client/graphql/mutations/queries.test.tsx index 43258af345..ce521ccf51 100644 --- a/test/client/graphql/mutations/queries.test.tsx +++ b/test/client/graphql/mutations/queries.test.tsx @@ -7,13 +7,13 @@ import { mockSingleLink } from '../../../../src/test-utils'; import { ApolloProvider, graphql, - compose, ChildProps, MutationFunc, } from '../../../../src'; - import stripSymbols from '../../../test-utils/stripSymbols'; +const compose = require('lodash/flowRight'); + describe('[mutations] query integration', () => { it('allows for passing optimisticResponse for a mutation', done => { const query = gql` diff --git a/test/client/graphql/shared-operations.test.tsx b/test/client/graphql/shared-operations.test.tsx index 58ff0202d2..93081f99dd 100644 --- a/test/client/graphql/shared-operations.test.tsx +++ b/test/client/graphql/shared-operations.test.tsx @@ -11,10 +11,11 @@ import { DataValue, graphql, withApollo, - compose, } from '../../../src'; import * as TestUtils from 'react-dom/test-utils'; +const compose = require('lodash/flowRight'); + describe('shared operations', () => { describe('withApollo', () => { it('passes apollo-client to props', () => { diff --git a/test/flow-usage.js b/test/flow-usage.js index 771491d312..503638d6be 100644 --- a/test/flow-usage.js +++ b/test/flow-usage.js @@ -12,8 +12,12 @@ // @flow import gql from 'graphql-tag'; import React from 'react'; -import { withApollo, compose, graphql } from '../src'; -import type { OperationComponent, QueryProps, ChildProps } from '../src'; +import { withApollo, graphql } from '../src'; +import type { + OperationComponent, + GraphqlQueryControls, + ChildProps, +} from '../src'; const query = gql` { @@ -59,7 +63,7 @@ const BasicClassWithData = withData(BasicComponent); // A class component with it's own variable type CmplxOwnProps = {| faz: string |}; type CmplxComponentProps = { - data: QueryProps & IQuery, + data: GraphqlQueryControls & IQuery, mutate: any, // The mutation is actually required or we get a error at the withData } & CmplxOwnProps; class CmplxComponent extends React.Component { @@ -86,7 +90,7 @@ const CmplxWithData = withFancyData(CmplxComponent); // since we don't rely on the ChildProps we don't need the mutate: any type Cmplx2OwnProps = { faz: string }; // We can have exact own props as we don't rely on the TMergedProps type Cmplx2ComponentProps = { - data: IQuery & QueryProps, + data: IQuery & GraphqlQueryControls, } & Cmplx2OwnProps; class Cmplx2Component extends React.Component { render() { @@ -137,7 +141,7 @@ type Response = { hero: Hero, }; -type Props = Response & QueryProps; +type Props = Response & GraphqlQueryControls; export type InputProps = { episode: string, diff --git a/typings/lodash.d.ts b/typings/lodash.d.ts deleted file mode 100644 index 136419dce8..0000000000 --- a/typings/lodash.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - LODASH -*/ -declare module 'lodash.isobject' { - import main = require('lodash/isObject'); - export = main; -} - -declare module 'lodash.isequal' { - import main = require('lodash/isEqual'); - export = main; -} - -declare module 'lodash.flatten' { - import main = require('lodash/flatten'); - export = main; -} - -declare module 'lodash.pick' { - import main = require('lodash/pick'); - export = main; -} diff --git a/yarn.lock b/yarn.lock index f2bbce97e9..c5952e8bbc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3928,10 +3928,6 @@ lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" -lodash.flowright@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/lodash.flowright/-/lodash.flowright-3.5.0.tgz#2b5fff399716d7e7dc5724fe9349f67065184d67" - lodash.includes@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" @@ -3976,10 +3972,6 @@ lodash.padstart@^4.1.0: version "4.6.1" resolved "https://registry.yarnpkg.com/lodash.padstart/-/lodash.padstart-4.6.1.tgz#d2e3eebff0d9d39ad50f5cbd1b52a7bce6bb611b" -lodash.pick@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" - lodash.restparam@^3.0.0: version "3.6.1" resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" @@ -6060,7 +6052,7 @@ vinyl@^0.5.0: clone-stats "^0.0.1" replace-ext "0.0.1" -vm2@patriksimek/vm2#custom_files: +"vm2@github:patriksimek/vm2#custom_files": version "3.5.0" resolved "https://codeload.github.com/patriksimek/vm2/tar.gz/7e82f90ac705fc44fad044147cb0df09b4c79a57"