From 4cccd6c267ea46215a11a27f1420da1db9d2cc39 Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 16:49:03 -0800 Subject: [PATCH 01/10] update apollo client dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7aa111d54..b31c39671c 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "uglify-js": "^2.6.2" }, "dependencies": { - "apollo-client": "^0.9.0 || ^0.10.0", + "apollo-client": "^1.0.0-rc.1", "graphql-anywhere": "^2.0.0", "graphql-tag": "^1.3.1", "hoist-non-react-statics": "^1.2.0", From 2b8ce9e9a6304faa09f7ff2557516dfbe750c9da Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 16:49:40 -0800 Subject: [PATCH 02/10] update Changelog.md --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index 8d8036a74c..18002fa456 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,9 @@ Expect active development and potentially significant breaking changes in the `0 ### vNext +### 1.0.0-rc.1 +- Update dependency to Apollo Client 1.0.0-rc.1 []() + ### 0.13.3 - Make sure that the cached rendered element has the correct type before returning it. [PR #505](https://github.com/apollographql/react-apollo/pull/505) - Move constructor initializing of props to componentWillMount. [PR #506](https://github.com/apollographql/react-apollo/pull/506) ([Issue #509](https://github.com/apollographql/react-apollo/issues/509)). From 187256aecca755001afafe892cea32e82e267ca9 Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 17:25:49 -0800 Subject: [PATCH 03/10] update tests to use fetchPolicy and set notifyOnNetworkStatusChange --- src/graphql.tsx | 9 +++++---- test/react-web/client/graphql/queries.test.tsx | 14 +++++++------- test/react-web/server/index.test.tsx | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/graphql.tsx b/src/graphql.tsx index dad57996e0..664e81d1f0 100644 --- a/src/graphql.tsx +++ b/src/graphql.tsx @@ -22,6 +22,7 @@ import ApolloClient, { ApolloStore, ApolloQueryResult, ApolloError, + // FetchPolicy, } from 'apollo-client'; import { @@ -45,15 +46,13 @@ export declare interface MutationOptions { variables?: Object; optimisticResponse?: Object; updateQueries?: MutationQueryReducersMap; - forceFetch?: boolean; } export declare interface QueryOptions { ssr?: boolean; variables?: { [key: string]: any }; - forceFetch?: boolean; returnPartialData?: boolean; - noFetch?: boolean; + fetchPolicy: string; // update this to FetchPolicy pollInterval?: number; // deprecated skip?: boolean; @@ -428,7 +427,9 @@ export default function graphql( const opts = this.calculateOptions() as any; if (opts.ssr === false) return false; - if (opts.forceFetch) delete opts.forceFetch; // ignore force fetch in SSR; + if (opts.fetchPolicy === 'network-only') { + opts.fetchPolicy = 'cache-first'; // ignore force fetch in SSR; + } const observable = this.client.watchQuery(assign({ query: document }, opts)); const result = observable.currentResult(); diff --git a/test/react-web/client/graphql/queries.test.tsx b/test/react-web/client/graphql/queries.test.tsx index 4695d68b01..918a12d28d 100644 --- a/test/react-web/client/graphql/queries.test.tsx +++ b/test/react-web/client/graphql/queries.test.tsx @@ -643,7 +643,7 @@ describe('queries', () => { let hasSkipped = false; let hasRequeried = false; - @graphql(query, { options: ({ skip }) => ({ skip, forceFetch: true }) }) + @graphql(query, { options: ({ skip }) => ({ skip, fetchPolicy: 'network-only' }) }) class Container extends React.Component {8 componentWillReceiveProps(newProps) { if (newProps.skip) { @@ -814,7 +814,7 @@ describe('queries', () => { const client = new ApolloClient({ networkInterface, addTypename: false }); @graphql(query, { - options: (props) => ({ variables: props, returnPartialData: count === 0 }), + options: (props) => ({ variables: props, fetchPolicy: count === 0 ? 'cache-and-network' : 'cache-first' }), }) class Container extends React.Component { componentWillReceiveProps({ data }) { @@ -1032,7 +1032,7 @@ describe('queries', () => { const client = new ApolloClient({ networkInterface, addTypename: false }); let count = 0; - @graphql(query, { options() { return { variables }; } }) + @graphql(query, { options() { return { variables, notifyOnNetworkStatusChange: false }; } }) class Container extends React.Component {8 componentWillReceiveProps(props) { count += 1; @@ -1489,7 +1489,7 @@ describe('queries', () => { const client = new ApolloClient({ networkInterface, addTypename: false }); let count = 0; - const Container = graphql(query, { options: () => ({ pollInterval: 75 }) })(() => { + const Container = graphql(query, { options: () => ({ pollInterval: 75, notifyOnNetworkStatusChange: false }) })(() => { count++; return null; }); @@ -1849,7 +1849,7 @@ describe('queries', () => { const client = new ApolloClient({ networkInterface, addTypename: false }); let wrapper, app, count = 0; - @graphql(query, { options: { pollInterval: 10 }}) + @graphql(query, { options: { pollInterval: 10, notifyOnNetworkStatusChange: false }}) class Container extends React.Component { componentWillReceiveProps(props) { if (count === 1) { // has data @@ -1873,7 +1873,7 @@ describe('queries', () => { wrapper = mount(app); }); - it('correctly sets loading state on remounted forcefetch', (done) => { + it('correctly sets loading state on remounted network-only query', (done) => { const query = gql`query pollingPeople { allPeople(first: 1) { people { name } } }`; const data = { allPeople: { people: [ { name: 'Darth Skywalker' } ] } }; const networkInterface = mockNetworkInterface( @@ -1886,7 +1886,7 @@ describe('queries', () => { const client = new ApolloClient({ networkInterface, addTypename: false }); let wrapper, app, count = 0; - @graphql(query, { options: { forceFetch: true }}) + @graphql(query, { options: { fetchPolicy: 'network-only' }}) class Container extends React.Component { componentWillMount() { if (count === 1) { diff --git a/test/react-web/server/index.test.tsx b/test/react-web/server/index.test.tsx index ac6effa146..35189dda15 100644 --- a/test/react-web/server/index.test.tsx +++ b/test/react-web/server/index.test.tsx @@ -163,7 +163,7 @@ describe('SSR', () => { }); }); - it('should allow forceFetch as an option and still render prefetched data', () => { + it('should allow network-only fetchPolicy as an option and still render prefetched data', () => { const query = gql`{ currentUser { firstName } }`; const data = { currentUser: { firstName: 'James' } }; @@ -172,7 +172,7 @@ describe('SSR', () => { ); const apolloClient = new ApolloClient({ networkInterface, addTypename: false }); - const WrappedElement = graphql(query, { options: { forceFetch: true }})(({ data }) => ( + const WrappedElement = graphql(query, { options: { fetchPolicy: 'network-only' }})(({ data }) => (
{data.loading ? 'loading' : data.currentUser.firstName}
)); From 90528cf404f208ae7341475b85661b231403e42e Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 17:26:32 -0800 Subject: [PATCH 04/10] update Changelog.md --- Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 18002fa456..2abe0a2b2a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,7 +5,7 @@ Expect active development and potentially significant breaking changes in the `0 ### vNext ### 1.0.0-rc.1 -- Update dependency to Apollo Client 1.0.0-rc.1 []() +- Update dependency to Apollo Client 1.0.0-rc.1 [PR #520](https://github.com/apollographql/react-apollo/pull/520) ### 0.13.3 - Make sure that the cached rendered element has the correct type before returning it. [PR #505](https://github.com/apollographql/react-apollo/pull/505) From 20dbbd1607b44ea7515c53366d5713641ae1ecd7 Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 17:26:38 -0800 Subject: [PATCH 05/10] 1.0.0-rc.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b31c39671c..d626deea38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-apollo", - "version": "0.13.3", + "version": "1.0.0-rc.1", "description": "React data container for Apollo Client", "main": "lib/index.js", "browser": "lib/browser.js", From bfb20b6f08963f66ad5b0a6c3aacbceba2a624fb Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 17:37:56 -0800 Subject: [PATCH 06/10] compile before running tests --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d626deea38..916fc6e728 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "typings": "lib/index.d.ts", "scripts": { "deploy": "npm run compile && npm test && npm publish", - "test": "jest", + "test": "npm run compile && jest", + "testonly": "jest", "test-watch": "jest --watch", "posttest": "npm run lint", "filesize": "npm run compile:browser && ./scripts/filesize.js --file=./dist/index.min.js --maxGzip=20", From a2d01de41b689fe212d3da0f2113ac99689060ac Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 17:38:11 -0800 Subject: [PATCH 07/10] make fetchPolicy optional and fix typings --- src/graphql.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphql.tsx b/src/graphql.tsx index 664e81d1f0..ae51e24864 100644 --- a/src/graphql.tsx +++ b/src/graphql.tsx @@ -52,7 +52,7 @@ export declare interface QueryOptions { ssr?: boolean; variables?: { [key: string]: any }; returnPartialData?: boolean; - fetchPolicy: string; // update this to FetchPolicy + fetchPolicy?: 'network-only' | 'cache-first' | 'cache-only' | 'cache-and-network'; // update this to FetchPolicy pollInterval?: number; // deprecated skip?: boolean; From de6648fbf146c86e7f3d74fe84159674894c8217 Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 18:40:03 -0800 Subject: [PATCH 08/10] remove returnPartialData --- src/graphql.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/graphql.tsx b/src/graphql.tsx index ae51e24864..d8925d3d44 100644 --- a/src/graphql.tsx +++ b/src/graphql.tsx @@ -51,7 +51,6 @@ export declare interface MutationOptions { export declare interface QueryOptions { ssr?: boolean; variables?: { [key: string]: any }; - returnPartialData?: boolean; fetchPolicy?: 'network-only' | 'cache-first' | 'cache-only' | 'cache-and-network'; // update this to FetchPolicy pollInterval?: number; // deprecated From 8e0e8c9d2fd67d1e15945e95dc13628318db89dc Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 19:24:59 -0800 Subject: [PATCH 09/10] use FetchPolicy from Apollo Client --- package.json | 2 +- src/graphql.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 916fc6e728..f9f016fc1e 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ "uglify-js": "^2.6.2" }, "dependencies": { - "apollo-client": "^1.0.0-rc.1", + "apollo-client": "^1.0.0-rc.2", "graphql-anywhere": "^2.0.0", "graphql-tag": "^1.3.1", "hoist-non-react-statics": "^1.2.0", diff --git a/src/graphql.tsx b/src/graphql.tsx index d8925d3d44..8c3878c3fd 100644 --- a/src/graphql.tsx +++ b/src/graphql.tsx @@ -22,7 +22,7 @@ import ApolloClient, { ApolloStore, ApolloQueryResult, ApolloError, - // FetchPolicy, + FetchPolicy, } from 'apollo-client'; import { @@ -51,7 +51,7 @@ export declare interface MutationOptions { export declare interface QueryOptions { ssr?: boolean; variables?: { [key: string]: any }; - fetchPolicy?: 'network-only' | 'cache-first' | 'cache-only' | 'cache-and-network'; // update this to FetchPolicy + fetchPolicy?: FetchPolicy; pollInterval?: number; // deprecated skip?: boolean; From 5fe88d83d4c3b03863b085e6771f18981f2f8f50 Mon Sep 17 00:00:00 2001 From: Jonas Helfer Date: Thu, 9 Mar 2017 19:25:09 -0800 Subject: [PATCH 10/10] 1.0.0-rc.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f9f016fc1e..370968c325 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-apollo", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "description": "React data container for Apollo Client", "main": "lib/index.js", "browser": "lib/browser.js",