From 331a17e3ef3aee9b0e100c1974bb935b922a6460 Mon Sep 17 00:00:00 2001 From: Jan Zimmek Date: Sun, 18 Mar 2018 14:37:21 +0100 Subject: [PATCH 01/95] await refetched queries before resolve mutation --- .../apollo-client/src/core/QueryManager.ts | 68 ++++++++++--------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/packages/apollo-client/src/core/QueryManager.ts b/packages/apollo-client/src/core/QueryManager.ts index 5c668ea5de9..0add95edcde 100644 --- a/packages/apollo-client/src/core/QueryManager.ts +++ b/packages/apollo-client/src/core/QueryManager.ts @@ -229,45 +229,49 @@ export class QueryManager { }), ); }, - complete: () => { - if (error) { - this.mutationStore.markMutationError(mutationId, error); - } - - this.dataStore.markMutationComplete({ - mutationId, - optimisticResponse, - }); - - this.broadcastQueries(); + complete: async () => { + try { + if (error) { + this.mutationStore.markMutationError(mutationId, error); + } - if (error) { - reject(error); - return; - } + this.dataStore.markMutationComplete({ + mutationId, + optimisticResponse, + }); - // allow for conditional refetches - // XXX do we want to make this the only API one day? - if (typeof refetchQueries === 'function') - refetchQueries = refetchQueries(storeResult as ExecutionResult); + this.broadcastQueries(); - refetchQueries.forEach(refetchQuery => { - if (typeof refetchQuery === 'string') { - this.refetchQueryByName(refetchQuery); + if (error) { + reject(error); return; } - this.query({ - query: refetchQuery.query, - variables: refetchQuery.variables, - fetchPolicy: 'network-only', - }); - }); - this.setQuery(mutationId, () => ({ document: undefined })); - if (errorPolicy === 'ignore' && storeResult && storeResult.errors) { - delete storeResult.errors; + // allow for conditional refetches + // XXX do we want to make this the only API one day? + if (typeof refetchQueries === 'function') + refetchQueries = refetchQueries(storeResult as ExecutionResult); + + for (const refetchQuery of refetchQueries) { + if (typeof refetchQuery === 'string') { + await this.refetchQueryByName(refetchQuery); + continue; + } + + await this.query({ + query: refetchQuery.query, + variables: refetchQuery.variables, + fetchPolicy: 'network-only', + }); + } + this.setQuery(mutationId, () => ({ document: undefined })); + if (errorPolicy === 'ignore' && storeResult && storeResult.errors) { + delete storeResult.errors; + } + resolve(storeResult as FetchResult); + } catch (completionError) { + reject(completionError); } - resolve(storeResult as FetchResult); }, }); }); From 46aed422c8a6d5447edce22f58c44bef69e677e0 Mon Sep 17 00:00:00 2001 From: Quentin Cuvillier Date: Wed, 6 Jun 2018 12:38:57 -0700 Subject: [PATCH 02/95] warn when user try to use apollo-boost as an apollo-client --- .../__tests__/__snapshots__/config.ts.snap | 10 +++ packages/apollo-boost/src/__tests__/config.ts | 10 +++ packages/apollo-boost/src/index.ts | 70 ++++++++++++++----- 3 files changed, 72 insertions(+), 18 deletions(-) create mode 100644 packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap diff --git a/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap b/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap new file mode 100644 index 00000000000..13b374a415a --- /dev/null +++ b/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`config warns about unsupported parameter 1`] = ` +Array [ + Array [ + "ApolloBoost was initialized with unsupported options: link +https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost#apollo-boost-options", + ], +] +`; diff --git a/packages/apollo-boost/src/__tests__/config.ts b/packages/apollo-boost/src/__tests__/config.ts index 4ef1496c25d..0efe46852ca 100644 --- a/packages/apollo-boost/src/__tests__/config.ts +++ b/packages/apollo-boost/src/__tests__/config.ts @@ -22,6 +22,16 @@ describe('config', () => { }, }; + it('warns about unsupported parameter', () => { + jest.spyOn(global.console, 'warn'); + + const client = new ApolloClient({ + link: [], + }); + + expect(global.console.warn.mock.calls).toMatchSnapshot(); + }); + it('allows you to pass in a request handler', () => { let requestCalled; diff --git a/packages/apollo-boost/src/index.ts b/packages/apollo-boost/src/index.ts index 54741384ad2..3db7b6648e1 100644 --- a/packages/apollo-boost/src/index.ts +++ b/packages/apollo-boost/src/index.ts @@ -25,8 +25,41 @@ export interface PresetConfig { cacheRedirects?: CacheResolverMap; } +// infer this list from the above interface +// using a typescript transform at compilation time. +const PRESET_CONFIG_KEYS = [ + 'request', + 'uri', + 'credentials', + 'headers', + 'fetchOptions', + 'clientState', + 'onError', + 'cacheRedirects', +]; + +function include(b: T, a: Array): boolean { + return a.indexOf(b) >= 0; +} + +function difference(a: Array, b: Array): Array { + return a.filter(x => !include(x, b)); +} + export default class DefaultClient extends ApolloClient { constructor(config: PresetConfig) { + if (config) { + const diff = difference(Object.keys(config), PRESET_CONFIG_KEYS); + + if (diff.length > 0) { + // prettier-ignore + console.warn( + `ApolloBoost was initialized with unsupported options: ${diff.join(' ')}\n` + + `https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost#apollo-boost-options`, + ); + } + } + const cache = config && config.cacheRedirects ? new InMemoryCache({ cacheRedirects: config.cacheRedirects }) @@ -52,24 +85,25 @@ export default class DefaultClient extends ApolloClient { const requestHandler = config && config.request - ? new ApolloLink((operation, forward) => - new Observable(observer => { - let handle: any; - Promise.resolve(operation) - .then(oper => config.request(oper)) - .then(() => { - handle = forward(operation).subscribe({ - next: observer.next.bind(observer), - error: observer.error.bind(observer), - complete: observer.complete.bind(observer), - }); - }) - .catch(observer.error.bind(observer)); - - return () => { - if (handle) handle.unsubscribe; - }; - }) + ? new ApolloLink( + (operation, forward) => + new Observable(observer => { + let handle: any; + Promise.resolve(operation) + .then(oper => config.request(oper)) + .then(() => { + handle = forward(operation).subscribe({ + next: observer.next.bind(observer), + error: observer.error.bind(observer), + complete: observer.complete.bind(observer), + }); + }) + .catch(observer.error.bind(observer)); + + return () => { + if (handle) handle.unsubscribe; + }; + }), ) : false; From 1ddbd69229defca5a7f50e47bfe6960da6d513e3 Mon Sep 17 00:00:00 2001 From: Quentin Cuvillier Date: Wed, 6 Jun 2018 14:45:13 -0700 Subject: [PATCH 03/95] add entry to CHANGELOG --- packages/apollo-boost/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/apollo-boost/CHANGELOG.md b/packages/apollo-boost/CHANGELOG.md index 71953df50e5..be65bb8449c 100644 --- a/packages/apollo-boost/CHANGELOG.md +++ b/packages/apollo-boost/CHANGELOG.md @@ -2,6 +2,8 @@ ### vNext +- The `apollo-boost` `ApolloClient` constructor warns about unsupported options. + [PR #3551](https://github.com/apollographql/apollo-client/pull/3551) - Allow `headers` and `credentials` to be passed in as configuration parameters to the `apollo-boost` `ApolloClient` constructor. [PR #3098](https://github.com/apollographql/apollo-client/pull/3098) From 96e76568aa30586324b77ccefb9900690b3074f8 Mon Sep 17 00:00:00 2001 From: Quentin Cuvillier Date: Fri, 8 Jun 2018 17:47:55 -0700 Subject: [PATCH 04/95] point to better doc --- .../apollo-boost/src/__tests__/__snapshots__/config.ts.snap | 2 +- packages/apollo-boost/src/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap b/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap index 13b374a415a..42a9d762e2f 100644 --- a/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap +++ b/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap @@ -4,7 +4,7 @@ exports[`config warns about unsupported parameter 1`] = ` Array [ Array [ "ApolloBoost was initialized with unsupported options: link -https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost#apollo-boost-options", +https://www.apollographql.com/docs/react/essentials/get-started.html#configuration", ], ] `; diff --git a/packages/apollo-boost/src/index.ts b/packages/apollo-boost/src/index.ts index 3db7b6648e1..223a60578e8 100644 --- a/packages/apollo-boost/src/index.ts +++ b/packages/apollo-boost/src/index.ts @@ -55,7 +55,7 @@ export default class DefaultClient extends ApolloClient { // prettier-ignore console.warn( `ApolloBoost was initialized with unsupported options: ${diff.join(' ')}\n` + - `https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost#apollo-boost-options`, + `https://www.apollographql.com/docs/react/essentials/get-started.html#configuration`, ); } } From ff0322d0fbd461cc072c097f0412ae5028eefed2 Mon Sep 17 00:00:00 2001 From: Jonas Kello Date: Wed, 13 Jun 2018 16:43:20 +0200 Subject: [PATCH 05/95] Fix refetchQueries context --- packages/apollo-client/src/core/QueryManager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/apollo-client/src/core/QueryManager.ts b/packages/apollo-client/src/core/QueryManager.ts index cd6baad4f45..cc183b5aa3d 100644 --- a/packages/apollo-client/src/core/QueryManager.ts +++ b/packages/apollo-client/src/core/QueryManager.ts @@ -264,6 +264,7 @@ export class QueryManager { query: refetchQuery.query, variables: refetchQuery.variables, fetchPolicy: 'network-only', + context, }); }); } From 3fdb931d7ffa3918c0845bf912e903e18381ed06 Mon Sep 17 00:00:00 2001 From: Mathias Vestergaard Date: Thu, 14 Jun 2018 19:40:19 +0200 Subject: [PATCH 06/95] Add optional generic type parms for variables on low level query/mutation/subscription methods --- packages/apollo-client/src/ApolloClient.ts | 44 +++++++++++++------ .../src/core/watchQueryOptions.ts | 17 ++++--- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/packages/apollo-client/src/ApolloClient.ts b/packages/apollo-client/src/ApolloClient.ts index 4f926296a04..3378726463d 100644 --- a/packages/apollo-client/src/ApolloClient.ts +++ b/packages/apollo-client/src/ApolloClient.ts @@ -14,7 +14,7 @@ import { } from 'apollo-utilities'; import { QueryManager } from './core/QueryManager'; -import { ApolloQueryResult } from './core/types'; +import { ApolloQueryResult, OperationVariables } from './core/types'; import { ObservableQuery } from './core/ObservableQuery'; import { Observable } from './util/Observable'; @@ -203,11 +203,16 @@ export default class ApolloClient implements DataProxy { * a description of store reactivity. * */ - public watchQuery(options: WatchQueryOptions): ObservableQuery { + public watchQuery( + options: WatchQueryOptions, + ): ObservableQuery { this.initQueryManager(); if (this.defaultOptions.watchQuery) { - options = { ...this.defaultOptions.watchQuery, ...options }; + options = { + ...this.defaultOptions.watchQuery, + ...options, + } as WatchQueryOptions; } // XXX Overwriting options is probably not the best way to do this long term... @@ -216,7 +221,7 @@ export default class ApolloClient implements DataProxy { (options.fetchPolicy === 'network-only' || options.fetchPolicy === 'cache-and-network') ) { - options = { ...options, fetchPolicy: 'cache-first' } as WatchQueryOptions; + options = { ...options, fetchPolicy: 'cache-first' }; } return this.queryManager.watchQuery(options); @@ -231,11 +236,15 @@ export default class ApolloClient implements DataProxy { * describe how this query should be treated e.g. whether it should hit the * server at all or just resolve from the cache, etc. */ - public query(options: QueryOptions): Promise> { + public query( + options: QueryOptions, + ): Promise> { this.initQueryManager(); if (this.defaultOptions.query) { - options = { ...this.defaultOptions.query, ...options }; + options = { ...this.defaultOptions.query, ...options } as QueryOptions< + TVariables + >; } if (options.fetchPolicy === 'cache-and-network') { @@ -247,7 +256,7 @@ export default class ApolloClient implements DataProxy { // XXX Overwriting options is probably not the best way to do this long // term... if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') { - options = { ...options, fetchPolicy: 'cache-first' } as QueryOptions; + options = { ...options, fetchPolicy: 'cache-first' }; } return this.queryManager.query(options); @@ -260,11 +269,16 @@ export default class ApolloClient implements DataProxy { * * It takes options as an object with the following keys and values: */ - public mutate(options: MutationOptions): Promise> { + public mutate( + options: MutationOptions, + ): Promise> { this.initQueryManager(); if (this.defaultOptions.mutate) { - options = { ...this.defaultOptions.mutate, ...options }; + options = { + ...this.defaultOptions.mutate, + ...options, + } as MutationOptions; } return this.queryManager.mutate(options); @@ -274,7 +288,9 @@ export default class ApolloClient implements DataProxy { * This subscribes to a graphql subscription according to the options specified and returns an * {@link Observable} which either emits received data or an error. */ - public subscribe(options: SubscriptionOptions): Observable { + public subscribe( + options: SubscriptionOptions, + ): Observable { this.initQueryManager(); return this.queryManager.startGraphQLSubscription(options); @@ -286,7 +302,7 @@ export default class ApolloClient implements DataProxy { * the root query. To start at a specific id returned by `dataIdFromObject` * use `readFragment`. */ - public readQuery( + public readQuery( options: DataProxy.Query, ): T | null { return this.initProxy().readQuery(options); @@ -303,7 +319,7 @@ export default class ApolloClient implements DataProxy { * in a document with multiple fragments then you must also specify a * `fragmentName`. */ - public readFragment( + public readFragment( options: DataProxy.Fragment, ): T | null { return this.initProxy().readFragment(options); @@ -314,7 +330,7 @@ export default class ApolloClient implements DataProxy { * the store. This method will start at the root query. To start at a a * specific id returned by `dataIdFromObject` then use `writeFragment`. */ - public writeQuery( + public writeQuery( options: DataProxy.WriteQueryOptions, ): void { const result = this.initProxy().writeQuery(options); @@ -333,7 +349,7 @@ export default class ApolloClient implements DataProxy { * in a document with multiple fragments then you must also specify a * `fragmentName`. */ - public writeFragment( + public writeFragment( options: DataProxy.WriteFragmentOptions, ): void { const result = this.initProxy().writeFragment(options); diff --git a/packages/apollo-client/src/core/watchQueryOptions.ts b/packages/apollo-client/src/core/watchQueryOptions.ts index e3ddf19ebc4..806e2cc2a71 100644 --- a/packages/apollo-client/src/core/watchQueryOptions.ts +++ b/packages/apollo-client/src/core/watchQueryOptions.ts @@ -131,7 +131,7 @@ export type SubscribeToMoreOptions< onError?: (error: Error) => void; }; -export interface SubscriptionOptions { +export interface SubscriptionOptions { /** * A GraphQL document, often created with `gql` from the `graphql-tag` * package, that contains a single subscription inside of it. @@ -142,12 +142,15 @@ export interface SubscriptionOptions { * An object that maps from the name of a variable as used in the subscription * GraphQL document to that variable's value. */ - variables?: { [key: string]: any }; + variables?: TVariables; } export type RefetchQueryDescription = Array; -export interface MutationBaseOptions { +export interface MutationBaseOptions< + T = { [key: string]: any }, + TVariables = OperationVariables +> { /** * An object that represents the result of this mutation that will be * optimistically stored before the server has actually returned a result. @@ -205,11 +208,13 @@ export interface MutationBaseOptions { * An object that maps from the name of a variable as used in the mutation * GraphQL document to that variable's value. */ - variables?: any; + variables?: TVariables; } -export interface MutationOptions - extends MutationBaseOptions { +export interface MutationOptions< + T = { [key: string]: any }, + TVariables = OperationVariables +> extends MutationBaseOptions { /** * A GraphQL document, often created with `gql` from the `graphql-tag` * package, that contains a single mutation inside of it. From 23679dd6e98823345cc7c2b27f222f3fd371c0d6 Mon Sep 17 00:00:00 2001 From: Mikael Carpenter Date: Fri, 22 Jun 2018 15:55:25 -0700 Subject: [PATCH 07/95] add a snippet linking to zen-observable. Add redirects that will make the current error/fetch policy links work. --- docs/_config.yml | 4 ++++ docs/source/api/apollo-client.md | 2 ++ 2 files changed, 6 insertions(+) diff --git a/docs/_config.yml b/docs/_config.yml index aeaf8d56559..d16b751d2a9 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -65,3 +65,7 @@ redirects: docs/react/api/react-apollo.html#graphql-mutation-options /docs/react/recipes/simple-example.html: docs/react/essentials/get-started.html + /docs/react/api/apollo-client.html#FetchPolicy: + docs/react/api/react-apollo.html#graphql-config-options-fetchPolicy + /docs/react/api/apollo-client.html#ErrorPolicy: + docs/react/api/react-apollo.html#graphql-config-options-errorPolicy diff --git a/docs/source/api/apollo-client.md b/docs/source/api/apollo-client.md index 0770b67353d..9d45b4fe470 100644 --- a/docs/source/api/apollo-client.md +++ b/docs/source/api/apollo-client.md @@ -49,6 +49,8 @@ The `ApolloClient` class is the core API for Apollo, and the one you'll need to

ObservableQuery

+Our Observables are extending the implementation in [`zen-observable`](https://github.com/zenparsing/zen-observable). Their documentation may provide additional context and API options for Observables. + {% tsapibox ObservableQuery.variables %} {% tsapibox ObservableQuery.result %} {% tsapibox ObservableQuery.currentResult %} From db06d598f89a9528eed7610d9c098677cb787298 Mon Sep 17 00:00:00 2001 From: Socialflasher <1169093+Gamezpedia@users.noreply.github.com> Date: Tue, 26 Jun 2018 02:56:16 +0500 Subject: [PATCH 08/95] graphql-tag is already included in apollo-boost! graphql-tag package is already included in apollo-boost . as the apollo-boost readme document says : What's in Apollo Boost Apollo Boost includes some packages that we think are essential to developing with Apollo Client. Here's what's in the box: apollo-client: Where all the magic happens apollo-cache-inmemory: Our recommended cache apollo-link-http: An Apollo Link for remote data fetching apollo-link-error: An Apollo Link for error handling apollo-link-state: An Apollo Link for local state management graphql-tag: Exports the gql function for your queries & mutations --- docs/source/essentials/get-started.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/source/essentials/get-started.md b/docs/source/essentials/get-started.md index 627e75c2c91..3034095b897 100644 --- a/docs/source/essentials/get-started.md +++ b/docs/source/essentials/get-started.md @@ -12,12 +12,11 @@ If you're an advanced user who would like to configure Apollo Client from scratc First, let's install some packages! ```bash -npm install apollo-boost react-apollo graphql-tag graphql --save +npm install apollo-boost react-apollo graphql --save ``` - `apollo-boost`: Package containing everything you need to set up Apollo Client - `react-apollo`: View layer integration for React -- `graphql-tag`: Necessary for parsing your GraphQL queries - `graphql`: Also parses your GraphQL queries > If you'd like to walk through this tutorial yourself, we recommend either running a new React project locally with [`create-react-app`](https://reactjs.org/docs/add-react-to-a-new-app.html) or creating a new React sandbox on [CodeSandbox](https://codesandbox.io/). For reference, we will be using [this Launchpad](https://launchpad.graphql.com/w5xlvm3vzz) as our GraphQL server for our sample app, which pulls exchange rate data from the Coinbase API. If you'd like to skip ahead and see the app we're about to build, you can view it on [CodeSandbox](https://codesandbox.io/s/nn9y2wzyw4). From 101606536c2cce4eaed12179c02bd9580b44cba6 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Wed, 27 Jun 2018 16:05:44 +0100 Subject: [PATCH 09/95] Fix `Cannot convert object to primitive value` If `root` is created from `Object.create(null)` then `String(root)` throws `Cannot convert object to primitive value` which results in the confusing error `Failed prop type: Cannot convert object to primitive value` instead of the expected error `Failed prop type: currentUser missing on {}` --- packages/graphql-anywhere/src/utilities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphql-anywhere/src/utilities.ts b/packages/graphql-anywhere/src/utilities.ts index cf48289b81a..4c78bcfbe8d 100644 --- a/packages/graphql-anywhere/src/utilities.ts +++ b/packages/graphql-anywhere/src/utilities.ts @@ -29,7 +29,7 @@ export function check(doc: DocumentNode, data: any): void { info: any, ) => { if (!{}.hasOwnProperty.call(root, info.resultKey)) { - throw new Error(`${info.resultKey} missing on ${root}`); + throw new Error(`${info.resultKey} missing on ${JSON.stringify(root)}`); } return root[info.resultKey]; }; From 63bae8d76509f0871e975ed0edfbffd0be0e247e Mon Sep 17 00:00:00 2001 From: "A.J. Roberts" Date: Fri, 29 Jun 2018 07:22:20 -0500 Subject: [PATCH 10/95] Fix typo in pkg name and remove word for clarity The `#import` syntax isn't officially part of the GraphQL spec as far as I can tell --- docs/source/recipes/babel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/recipes/babel.md b/docs/source/recipes/babel.md index 05a63478a7d..e8a3a45b167 100644 --- a/docs/source/recipes/babel.md +++ b/docs/source/recipes/babel.md @@ -71,7 +71,7 @@ const query = gql` `; ``` -## Using babel-plugin-graphql-ast +## Using babel-plugin-import-graphql Install the plugin in your dev dependencies: @@ -143,4 +143,4 @@ const query = gql` `; ``` -With `babel-plugin-import-graphql`, you can just include your fragment in your GraphQL file along-side whatever uses it, or even import it from a separate file using the GraphQL `#import` syntax. See the [README](https://github.com/detrohutt/babel-plugin-import-graphql) for more information. +With `babel-plugin-import-graphql`, you can just include your fragment in your GraphQL file along-side whatever uses it, or even import it from a separate file using the `#import` syntax. See the [README](https://github.com/detrohutt/babel-plugin-import-graphql) for more information. From d1cbe8029ca68603fcfff17279f49a471fe9c24d Mon Sep 17 00:00:00 2001 From: jfurler Date: Mon, 2 Jul 2018 15:29:54 +1000 Subject: [PATCH 11/95] Add __typename and id properties to dataIdFromObject parameter --- packages/apollo-cache-inmemory/src/types.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/apollo-cache-inmemory/src/types.ts b/packages/apollo-cache-inmemory/src/types.ts index 36eee6da50d..cd6d07a1e14 100644 --- a/packages/apollo-cache-inmemory/src/types.ts +++ b/packages/apollo-cache-inmemory/src/types.ts @@ -3,7 +3,13 @@ import { FragmentMatcher } from 'graphql-anywhere'; import { Transaction } from 'apollo-cache'; import { IdValue, StoreValue } from 'apollo-utilities'; -export type IdGetter = (value: Object) => string | null | undefined; +export interface IdGetterObj extends Object { + __typename?: string; + id?: string; +} +export declare type IdGetter = ( + value: IdGetterObj, +) => string | null | undefined; /** * This is an interface used to access, set and remove From f477936a82364740ae2ebed6ca5a6091a7b188df Mon Sep 17 00:00:00 2001 From: Harkirat Saluja Date: Wed, 4 Jul 2018 23:40:56 +0530 Subject: [PATCH 12/95] Import text fiex --- docs/source/advanced/network-layer.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/advanced/network-layer.md b/docs/source/advanced/network-layer.md index 9114a83d3fb..7d96d524e83 100644 --- a/docs/source/advanced/network-layer.md +++ b/docs/source/advanced/network-layer.md @@ -30,7 +30,7 @@ const client = new ApolloClient({ And if you needed to pass additional options to [`fetch`](https://github.github.io/fetch/): ```js -import ApolloClient from 'apollo-client'; +import { ApolloClient } from 'apollo-client'; import { HttpLink } from 'apollo-link-http'; const link = new HttpLink({ @@ -52,7 +52,7 @@ Apollo Link is designed from day one to be easy to use middleware on your reques The following examples shows how you'd create a middleware. In both examples, we'll show how you would add an authentication token to the HTTP header of the requests being sent by the client. ```js -import ApolloClient from 'apollo-client'; +import { ApolloClient } from 'apollo-client'; import { HttpLink } from 'apollo-link-http'; import { ApolloLink, concat } from 'apollo-link'; @@ -79,7 +79,7 @@ The above example shows the use of a single middleware joined with the HttpLink. The following example shows the use of multiple middlewares passed as an array: ```js -import ApolloClient from 'apollo-client'; +import { ApolloClient } from 'apollo-client'; import { HttpLink } from 'apollo-link-http'; import { ApolloLink, from } from 'apollo-link'; @@ -133,7 +133,7 @@ Much like middlewares, Apollo Link was designed to make afterwares easy and powe The following example demonstrates how to implement an afterware function. ```js -import ApolloClient from 'apollo-client'; +import { ApolloClient } from 'apollo-client'; import { HttpLink } from 'apollo-link-http'; import { onError } from 'apollo-link-error' From e1f351dc60bf15ab421fd553e5b0c380005981fb Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Sun, 8 Jul 2018 19:41:50 +0300 Subject: [PATCH 13/95] Adds link to lit-apollo --- docs/source/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/index.md b/docs/source/index.md index 01bfe12ab04..d6d1c748d7b 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -32,7 +32,9 @@ Most of this sites documentation examples are written using React, but Apollo Cl - [Vue](./integrations.html#vue) - [Meteor](./recipes/meteor.html) - [Ember](./integrations.html#ember) +- Web Components - [Polymer](./integrations.html#polymer) + - [lit-apollo](./integrations.html#lit-apollo) - Native mobile - [Native iOS with Swift](/docs/ios) - [Native Android with Java](https://github.com/apollographql/apollo-android) From c3b2a5fecd79ea67b97f5b3305aeb1e226df340e Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Sun, 8 Jul 2018 19:48:49 +0300 Subject: [PATCH 14/95] Adds info to integrations page --- docs/source/integrations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/integrations.md b/docs/source/integrations.md index d13514f70f2..f530f5afd51 100644 --- a/docs/source/integrations.md +++ b/docs/source/integrations.md @@ -25,3 +25,5 @@ There are two [Ember](http://emberjs.com/) integrations available:

Polymer

A [Polymer](https://www.polymer-project.org/) integration is maintained by Arun Kumar T K. See the Github [repository](https://github.com/aruntk/polymer-apollo) for more details. +

lit-apollo

+A set of custom-element base classes by Benny Powers that extend from LitElement which let you easily compose front-end apps in a framework-agnostic way. [`lit-apollo`](https://github.com/bennypowers/lit-apollo) is maintained by Benny Powers. From c80374949be2af068961c4d1ede707f6fce00276 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Sun, 8 Jul 2018 23:34:28 +0300 Subject: [PATCH 15/95] Update integrations.md --- docs/source/integrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/integrations.md b/docs/source/integrations.md index f530f5afd51..ee916e5d11d 100644 --- a/docs/source/integrations.md +++ b/docs/source/integrations.md @@ -26,4 +26,4 @@ There are two [Ember](http://emberjs.com/) integrations available: A [Polymer](https://www.polymer-project.org/) integration is maintained by Arun Kumar T K. See the Github [repository](https://github.com/aruntk/polymer-apollo) for more details.

lit-apollo

-A set of custom-element base classes by Benny Powers that extend from LitElement which let you easily compose front-end apps in a framework-agnostic way. [`lit-apollo`](https://github.com/bennypowers/lit-apollo) is maintained by Benny Powers. +A set of custom-element base classes that extend from LitElement which let you easily compose front-end apps in a framework-agnostic way. [`lit-apollo`](https://github.com/bennypowers/lit-apollo) is maintained by Benny Powers. From c8b3d4887b6207e94f6ee055050c8c03f2e2eae4 Mon Sep 17 00:00:00 2001 From: Quentin Cuvillier Date: Wed, 11 Jul 2018 14:47:01 -0700 Subject: [PATCH 16/95] update list of keys --- packages/apollo-boost/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/apollo-boost/src/index.ts b/packages/apollo-boost/src/index.ts index 74a24e79241..2e17e9fff33 100644 --- a/packages/apollo-boost/src/index.ts +++ b/packages/apollo-boost/src/index.ts @@ -35,10 +35,12 @@ const PRESET_CONFIG_KEYS = [ 'uri', 'credentials', 'headers', + 'fetch', 'fetchOptions', 'clientState', 'onError', 'cacheRedirects', + 'cache', ]; function include(b: T, a: Array): boolean { From 6c5723c4adcbef0342e628caad6ce429abdbeaf2 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 16 Jul 2018 10:37:34 -0400 Subject: [PATCH 17/95] Slight `zen-observable` reference changes --- docs/source/api/apollo-client.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/api/apollo-client.md b/docs/source/api/apollo-client.md index 8066fc2669c..470ce0d788c 100644 --- a/docs/source/api/apollo-client.md +++ b/docs/source/api/apollo-client.md @@ -50,7 +50,7 @@ The `ApolloClient` class is the core API for Apollo, and the one you'll need to

ObservableQuery

-Our Observables are extending the implementation in [`zen-observable`](https://github.com/zenparsing/zen-observable). Their documentation may provide additional context and API options for Observables. +`ApolloClient` Observables extend the Observables implementation provided by [`zen-observable`](https://github.com/zenparsing/zen-observable). Refer to the `zen-observable` documentation for additional context and API options. {% tsapibox ObservableQuery.variables %} {% tsapibox ObservableQuery.result %} From f7bec305bd251a3d5d8cd8a1e16d80ee3e452b39 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 16 Jul 2018 10:39:13 -0400 Subject: [PATCH 18/95] Changelog update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8863efa2843..442369bdca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ [@hwillson](https://github.com/hwillson) in [#3644](https://github.com/apollographql/apollo-client/pull/3644) [@gbau](https://github.com/gbau) in [#3644](https://github.com/apollographql/apollo-client/pull/3600) [@chentsulin](https://github.com/chentsulin) in [#3608](https://github.com/apollographql/apollo-client/pull/3608) + [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) - Updated `graphql` `peerDependencies` to handle 14.x versions. [@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) From 5f0501701b8ddbc82532a62e6345789a94191245 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 16 Jul 2018 12:39:03 -0400 Subject: [PATCH 19/95] Changelog updates --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 442369bdca9..95744702bc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ [@hwillson](https://github.com/hwillson) in [#3644](https://github.com/apollographql/apollo-client/pull/3644) [@gbau](https://github.com/gbau) in [#3644](https://github.com/apollographql/apollo-client/pull/3600) [@chentsulin](https://github.com/chentsulin) in [#3608](https://github.com/apollographql/apollo-client/pull/3608) - [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) + [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) + [@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612) - Updated `graphql` `peerDependencies` to handle 14.x versions. [@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) @@ -24,6 +25,9 @@ - Add support for arrays to `graphql-anywhere`'s filter utility. [@jsweet314](https://github.com/jsweet314) in [#3591](https://github.com/apollographql/apollo-client/pull/3591) +- Fix `Cannot convert object to primitive value` error that was showing up + when attempting to report a missing property on an object. + [@benjie](https://github.com/benjie) in [#3618](https://github.com/apollographql/apollo-client/pull/3618) ## 2.3.5 (June 19, 2018) From af179df75385aa3135ad6d83aff78b95a9e93d95 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 16 Jul 2018 15:41:57 -0400 Subject: [PATCH 20/95] Changelog update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 442369bdca9..817252e62ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) - Updated `graphql` `peerDependencies` to handle 14.x versions. [@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) +- Add optional generic type params for variables on low level methods. + [@mvestergaard](https://github.com/mvestergaard) in [#3588](https://github.com/apollographql/apollo-client/pull/3588) ### Apollo Boost (vNext) From 2544bdd14a77101cd56b3651b9c7664c2221c932 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 17 Jul 2018 08:38:11 -0400 Subject: [PATCH 21/95] Changelog update --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd064076e02..6211bc1ca48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,12 @@ when attempting to report a missing property on an object. [@benjie](https://github.com/benjie) in [#3618](https://github.com/apollographql/apollo-client/pull/3618) +### Apollo Cache In-Memory (vNext) + +- Add `__typename` and `id` properties to `dataIdFromObject` parameter + (typescript) + [@jfurler](https://github.com/jfurler) in [#3641](https://github.com/apollographql/apollo-client/pull/3641) + ## 2.3.5 (June 19, 2018) ### Apollo Client (2.3.5) From 70cfa8c4825dee49f93a3aa6ede970682071b370 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 17 Jul 2018 15:51:28 -0400 Subject: [PATCH 22/95] Changelog updates --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6211bc1ca48..318e45712aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ [@gbau](https://github.com/gbau) in [#3644](https://github.com/apollographql/apollo-client/pull/3600) [@chentsulin](https://github.com/chentsulin) in [#3608](https://github.com/apollographql/apollo-client/pull/3608) [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) - [@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612) + [@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612) + [@jinxac](https://github.com/jinxac) in [#3647](https://github.com/apollographql/apollo-client/pull/3647) - Updated `graphql` `peerDependencies` to handle 14.x versions. [@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) - Add optional generic type params for variables on low level methods. From b420d0801073528c8d7595350a1271b95352d925 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Tue, 17 Jul 2018 14:45:00 -0700 Subject: [PATCH 23/95] docs: fix typo in "localhost". --- docs/source/recipes/meteor.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/recipes/meteor.md b/docs/source/recipes/meteor.md index 1a5fd2b0480..e61b949fa1c 100644 --- a/docs/source/recipes/meteor.md +++ b/docs/source/recipes/meteor.md @@ -152,7 +152,7 @@ The store is normalized by default with `__typename` + `_id` identifiers. See [s `createMeteorNetworkInterface(customNetworkInterface = {})` `customNetworkInterface` is an optional object that replaces fields of the default configuration: -- `uri`: `Meteor.absoluteUrl('graphql')`, points to the default GraphQL server endpoint, such as http://locahost:3000/graphql or https://www.my-app.com/graphql. +- `uri`: `Meteor.absoluteUrl('graphql')`, points to the default GraphQL server endpoint, such as http://localhost:3000/graphql or https://www.my-app.com/graphql. - `opts`: `{}`, additional [`FetchOptions`](https://github.github.io/fetch#options) passed to the [`NetworkInterface`](http://dev.apollodata.com/core/network.html#createNetworkInterface). - `useMeteorAccounts`: `true`, enable the Meteor User Accounts middleware to identify the user with every request thanks to her login token. - `batchingInterface`: `true`, use a [`BatchedNetworkInterface`](http://dev.apollodata.com/core/network.html#query-batching) by default instead of [`NetworkInterface`](http://dev.apollodata.com/core/network.html#network-interfaces). From 6ec5132ddc7cae80a6464759b15cafec014f6ad7 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Tue, 17 Jul 2018 14:46:00 -0700 Subject: [PATCH 24/95] docs: Use example.com rather than my-app.com. Example.com is an IANA-recognized[[0]] test domain intended for using in examples, whereas my-app.com is an actual business. I only came across this while checking for broken links. Luckily, the broken link checker that I use ignores example.com (as I'd _almost_ expect it to, because of the IANA "Example" designation.) [0]: https://www.iana.org/domains/reserved --- docs/source/recipes/meteor.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/recipes/meteor.md b/docs/source/recipes/meteor.md index e61b949fa1c..6c9e7146216 100644 --- a/docs/source/recipes/meteor.md +++ b/docs/source/recipes/meteor.md @@ -152,7 +152,7 @@ The store is normalized by default with `__typename` + `_id` identifiers. See [s `createMeteorNetworkInterface(customNetworkInterface = {})` `customNetworkInterface` is an optional object that replaces fields of the default configuration: -- `uri`: `Meteor.absoluteUrl('graphql')`, points to the default GraphQL server endpoint, such as http://localhost:3000/graphql or https://www.my-app.com/graphql. +- `uri`: `Meteor.absoluteUrl('graphql')`, points to the default GraphQL server endpoint, such as http://localhost:3000/graphql or https://www.example.com/graphql. - `opts`: `{}`, additional [`FetchOptions`](https://github.github.io/fetch#options) passed to the [`NetworkInterface`](http://dev.apollodata.com/core/network.html#createNetworkInterface). - `useMeteorAccounts`: `true`, enable the Meteor User Accounts middleware to identify the user with every request thanks to her login token. - `batchingInterface`: `true`, use a [`BatchedNetworkInterface`](http://dev.apollodata.com/core/network.html#query-batching) by default instead of [`NetworkInterface`](http://dev.apollodata.com/core/network.html#network-interfaces). From b34a7b387cb6f94bff1f4120ce1bb17de3f6e8fe Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Tue, 17 Jul 2018 22:24:52 -0700 Subject: [PATCH 25/95] Pagination: fix typo --- docs/source/features/pagination.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/features/pagination.md b/docs/source/features/pagination.md index 299e35b2fce..f2943d77b72 100644 --- a/docs/source/features/pagination.md +++ b/docs/source/features/pagination.md @@ -208,4 +208,4 @@ const FEED_QUERY = gql` `; ``` -This would result in the accumulated feed in every query or `fetchMore` being placed in the store under the `feed` key, which we could later use of imperative store updates. In this example, we also use the `@connection` directive's optional `filter` argument, which allows us to include some arguments of the query in the store key. In this case, we want to include the `type` query argument in the store key, which results in multiple store values that accumulate pages from each type of feed. +This would result in the accumulated feed in every query or `fetchMore` being placed in the store under the `feed` key, which we could later use for imperative store updates. In this example, we also use the `@connection` directive's optional `filter` argument, which allows us to include some arguments of the query in the store key. In this case, we want to include the `type` query argument in the store key, which results in multiple store values that accumulate pages from each type of feed. From b56d1f684a14fc1d2520fefe65d371b5b3d54cab Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Wed, 18 Jul 2018 15:33:25 -0700 Subject: [PATCH 26/95] docs: Update link to `create-react-app` instructions. The existing page for "Add React to a New App" (previously; now broken: https://reactjs.org/docs/add-react-to-a-new-app.html) has been moved to https://reactjs.org/docs/create-a-new-react-app.html. This updates the documentation to accommodate that change! --- docs/source/essentials/get-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/essentials/get-started.md b/docs/source/essentials/get-started.md index 07e612b812c..1b467193a1e 100644 --- a/docs/source/essentials/get-started.md +++ b/docs/source/essentials/get-started.md @@ -19,7 +19,7 @@ npm install apollo-boost react-apollo graphql --save - `react-apollo`: View layer integration for React - `graphql`: Also parses your GraphQL queries -> If you'd like to walk through this tutorial yourself, we recommend either running a new React project locally with [`create-react-app`](https://reactjs.org/docs/add-react-to-a-new-app.html) or creating a new React sandbox on [CodeSandbox](https://codesandbox.io/). For reference, we will be using [this Launchpad](https://launchpad.graphql.com/w5xlvm3vzz) as our GraphQL server for our sample app, which pulls exchange rate data from the Coinbase API. If you'd like to skip ahead and see the app we're about to build, you can view it on [CodeSandbox](https://codesandbox.io/s/nn9y2wzyw4). +> If you'd like to walk through this tutorial yourself, we recommend either running a new React project locally with [`create-react-app`](https://reactjs.org/docs/create-a-new-react-app.html) or creating a new React sandbox on [CodeSandbox](https://codesandbox.io/). For reference, we will be using [this Launchpad](https://launchpad.graphql.com/w5xlvm3vzz) as our GraphQL server for our sample app, which pulls exchange rate data from the Coinbase API. If you'd like to skip ahead and see the app we're about to build, you can view it on [CodeSandbox](https://codesandbox.io/s/nn9y2wzyw4).

Create a client

From 2d076d81fd2e4c273600f4776660367e4d2379c4 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 17 Jul 2018 22:43:20 +0000 Subject: [PATCH 27/95] chore(deps): update dependency tslint to v5.11.0 --- packages/apollo-boost/package.json | 2 +- packages/apollo-cache-inmemory/package.json | 2 +- packages/apollo-cache/package.json | 2 +- packages/apollo-client/package.json | 2 +- packages/apollo-utilities/package.json | 2 +- packages/graphql-anywhere/package.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/apollo-boost/package.json b/packages/apollo-boost/package.json index 302d959948d..338c349b4b0 100644 --- a/packages/apollo-boost/package.json +++ b/packages/apollo-boost/package.json @@ -54,7 +54,7 @@ "lodash": "4.17.10", "rimraf": "2.6.2", "ts-jest": "20.0.14", - "tslint": "5.10.0", + "tslint": "5.11.0", "typescript": "2.9.2", "uglifyjs": "2.4.11" }, diff --git a/packages/apollo-cache-inmemory/package.json b/packages/apollo-cache-inmemory/package.json index ce376ccddbb..3407c5c3180 100644 --- a/packages/apollo-cache-inmemory/package.json +++ b/packages/apollo-cache-inmemory/package.json @@ -59,7 +59,7 @@ "rimraf": "2.6.2", "rollup": "0.62.0", "ts-jest": "20.0.14", - "tslint": "5.10.0", + "tslint": "5.11.0", "typescript": "2.9.2", "uglifyjs": "2.4.11" }, diff --git a/packages/apollo-cache/package.json b/packages/apollo-cache/package.json index 8a82019c3aa..52f12acaee1 100644 --- a/packages/apollo-cache/package.json +++ b/packages/apollo-cache/package.json @@ -52,7 +52,7 @@ "rollup": "0.62.0", "rollup-plugin-node-resolve": "3.3.0", "ts-jest": "20.0.14", - "tslint": "5.10.0", + "tslint": "5.11.0", "typescript": "2.9.2", "uglifyjs": "2.4.11" }, diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index 97a4a38aa83..ded2677e3ed 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -80,7 +80,7 @@ "rollup": "0.62.0", "rxjs": "6.2.2", "ts-jest": "20.0.14", - "tslint": "5.10.0", + "tslint": "5.11.0", "typescript": "2.9.2", "uglify-js": "3.4.4", "webpack": "3.12.0", diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index 89657bbbbdf..d678739c0ba 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -55,7 +55,7 @@ "rimraf": "2.6.2", "rollup": "0.62.0", "ts-jest": "20.0.14", - "tslint": "5.10.0", + "tslint": "5.11.0", "typescript": "2.9.2", "uglifyjs": "2.4.11" }, diff --git a/packages/graphql-anywhere/package.json b/packages/graphql-anywhere/package.json index a4f892a267d..c584ade2fcd 100644 --- a/packages/graphql-anywhere/package.json +++ b/packages/graphql-anywhere/package.json @@ -57,7 +57,7 @@ "react-dom": "15.6.2", "rollup": "0.62.0", "ts-jest": "20.0.14", - "tslint": "5.10.0", + "tslint": "5.11.0", "typescript": "2.9.2", "uglify": "0.1.5" }, From d3273269d7e978785beab21c2823e0a52a743711 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 19 Jul 2018 02:42:38 +0000 Subject: [PATCH 28/95] chore(deps): update dependency uglify-js to v3.4.5 --- packages/apollo-client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index ded2677e3ed..73bd30efbec 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -82,7 +82,7 @@ "ts-jest": "20.0.14", "tslint": "5.11.0", "typescript": "2.9.2", - "uglify-js": "3.4.4", + "uglify-js": "3.4.5", "webpack": "3.12.0", "webpack-bundle-analyzer": "2.13.1" }, From 920ffe28258593830840e30adb488d34a8d8adc7 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 19 Jul 2018 10:10:55 -0400 Subject: [PATCH 29/95] Changelog updates --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 318e45712aa..7e81893395f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) [@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612) [@jinxac](https://github.com/jinxac) in [#3647](https://github.com/apollographql/apollo-client/pull/3647) + [@abernix](https://github.com/abernix) in [#3705](https://github.com/apollographql/apollo-client/pull/3705) - Updated `graphql` `peerDependencies` to handle 14.x versions. [@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) - Add optional generic type params for variables on low level methods. From 90581787250bca8618aacd3795053b17944142d5 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 19 Jul 2018 10:13:15 -0400 Subject: [PATCH 30/95] Changelog updates --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e81893395f..785d3085941 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,9 @@ [@chentsulin](https://github.com/chentsulin) in [#3608](https://github.com/apollographql/apollo-client/pull/3608) [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) [@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612) - [@jinxac](https://github.com/jinxac) in [#3647](https://github.com/apollographql/apollo-client/pull/3647) - [@abernix](https://github.com/abernix) in [#3705](https://github.com/apollographql/apollo-client/pull/3705) + [@jinxac](https://github.com/jinxac) in [#3647](https://github.com/apollographql/apollo-client/pull/3647) + [@abernix](https://github.com/abernix) in [#3705](https://github.com/apollographql/apollo-client/pull/3705) + [@dandv](https://github.com/dandv) in [#3703](https://github.com/apollographql/apollo-client/pull/3703) - Updated `graphql` `peerDependencies` to handle 14.x versions. [@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) - Add optional generic type params for variables on low level methods. From 2eee596a877574ad40d9eac1d7d488b948b53b19 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 19 Jul 2018 14:47:17 -0400 Subject: [PATCH 31/95] Add test to make sure refetch uses original query context --- .../apollo-client/src/__mocks__/mockLinks.ts | 8 +- .../src/core/__tests__/QueryManager/index.ts | 79 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/packages/apollo-client/src/__mocks__/mockLinks.ts b/packages/apollo-client/src/__mocks__/mockLinks.ts index efee5789c24..50ccfdcdb34 100644 --- a/packages/apollo-client/src/__mocks__/mockLinks.ts +++ b/packages/apollo-client/src/__mocks__/mockLinks.ts @@ -8,11 +8,15 @@ import { import { print } from 'graphql/language/printer'; +interface MockApolloLink extends ApolloLink { + operation?: Operation; +} + // Pass in multiple mocked responses, so that you can test flows that end up // making multiple queries to the server export function mockSingleLink( ...mockedResponses: MockedResponse[] -): ApolloLink { +): MockApolloLink { return new MockLink(mockedResponses); } @@ -40,6 +44,7 @@ export interface MockedSubscription { } export class MockLink extends ApolloLink { + public operation: Operation; private mockedResponsesByKey: { [key: string]: MockedResponse[] } = {}; constructor(mockedResponses: MockedResponse[]) { @@ -60,6 +65,7 @@ export class MockLink extends ApolloLink { } public request(operation: Operation) { + this.operation = operation; const key = requestToKey(operation); const responses = this.mockedResponsesByKey[key]; if (!responses || responses.length === 0) { diff --git a/packages/apollo-client/src/core/__tests__/QueryManager/index.ts b/packages/apollo-client/src/core/__tests__/QueryManager/index.ts index 7229a29bf4d..91ad49bdd87 100644 --- a/packages/apollo-client/src/core/__tests__/QueryManager/index.ts +++ b/packages/apollo-client/src/core/__tests__/QueryManager/index.ts @@ -4362,6 +4362,85 @@ describe('QueryManager', () => { ); }); + it('should refetch using the original query context (if any)', () => { + const mutation = gql` + mutation changeAuthorName { + changeAuthorName(newName: "Jack Smith") { + firstName + lastName + } + } + `; + const mutationData = { + changeAuthorName: { + firstName: 'Jack', + lastName: 'Smith', + }, + }; + const query = gql` + query getAuthors($id: ID!) { + author(id: $id) { + firstName + lastName + } + } + `; + const data = { + author: { + firstName: 'John', + lastName: 'Smith', + }, + }; + const secondReqData = { + author: { + firstName: 'Jane', + lastName: 'Johnson', + }, + }; + const variables = { id: '1234' }; + const queryManager = mockQueryManager( + { + request: { query, variables }, + result: { data }, + }, + { + request: { query, variables }, + result: { data: secondReqData }, + }, + { + request: { query: mutation }, + result: { data: mutationData }, + }, + ); + + const headers = { + someHeader: 'some value', + }; + const observable = queryManager.watchQuery({ + query, + variables, + context: { + headers, + }, + notifyOnNetworkStatusChange: false, + }); + + return observableToPromise( + { observable }, + result => { + queryManager.mutate({ + mutation, + refetchQueries: ['getAuthors'], + }); + }, + result => { + const context = queryManager.link.operation.getContext(); + expect(context.headers).not.toBeUndefined(); + expect(context.headers.someHeader).toEqual(headers.someHeader); + }, + ); + }); + afterEach(done => { // restore standard method console.warn = oldWarn; From 019a0d4fd4d176cb7fc83f8db2296eb0e924ccd9 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 19 Jul 2018 15:04:55 -0400 Subject: [PATCH 32/95] Revert `context` changes --- packages/apollo-client/src/core/QueryManager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/apollo-client/src/core/QueryManager.ts b/packages/apollo-client/src/core/QueryManager.ts index a22c9bef56f..f543bf79d69 100644 --- a/packages/apollo-client/src/core/QueryManager.ts +++ b/packages/apollo-client/src/core/QueryManager.ts @@ -264,7 +264,6 @@ export class QueryManager { query: refetchQuery.query, variables: refetchQuery.variables, fetchPolicy: 'network-only', - context, }); }); } From 13572f47a0dba3db73e230802eacba4f18a6a6d3 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 19 Jul 2018 15:24:27 -0400 Subject: [PATCH 33/95] Update `mutate` `context` docs Mention that `context` changes are applied to the mutation only, not `refetchQueries`. --- packages/apollo-client/src/core/watchQueryOptions.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/apollo-client/src/core/watchQueryOptions.ts b/packages/apollo-client/src/core/watchQueryOptions.ts index 806e2cc2a71..fdbffb7d0fc 100644 --- a/packages/apollo-client/src/core/watchQueryOptions.ts +++ b/packages/apollo-client/src/core/watchQueryOptions.ts @@ -222,7 +222,14 @@ export interface MutationOptions< mutation: DocumentNode; /** - * Context to be passed to link execution chain + * The context to be passed to the link execution chain. This context will + * only be used with the mutation. It will not be used with + * `refetchQueries`. Refetched queries use the context they were + * initialized with (since the intitial context is stored as part of the + * `ObservableQuery` instance). If a specific context is needed when + * refetching queries, make sure it is configured (via the + * [`query` `context` option](/docs/react/api/apollo-client.html#ApolloClient.query)) + * when the query is first initialized/run. */ context?: any; From f4db8c3fc4e0b3b32bb3de20dc53169b18dd82b5 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 19 Jul 2018 20:19:44 -0400 Subject: [PATCH 34/95] Adjust `dataIdFromObject` logic to handle ID's with a value of 0 If a custom `dataIdFromObject` function returns a numeric ID with the value 0, it's seen as being a falsy value. This then prevents the query result associated with the ID from being written to the store. These changes adjust the falsy check to accommodate 0 based custom ID's. Fixes #2164. --- .../src/__tests__/writeToStore.ts | 42 +++++++++++++++++++ .../apollo-cache-inmemory/src/writeToStore.ts | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts b/packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts index 8731a614206..1d9355a2347 100644 --- a/packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts +++ b/packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts @@ -1207,6 +1207,48 @@ describe('writing to the store', () => { }); }); + it('should write to store if `dataIdFromObject` returns an ID of 0', () => { + const query = gql` + query { + author { + firstName + id + __typename + } + } + `; + const data = { + author: { + id: 0, + __typename: 'Author', + firstName: 'John', + }, + }; + const expStore = defaultNormalizedCacheFactory({ + ROOT_QUERY: { + author: { + id: 0, + typename: 'Author', + type: 'id', + generated: false, + }, + }, + 0: { + id: data.author.id, + __typename: data.author.__typename, + firstName: data.author.firstName, + }, + }); + + expect( + writeQueryToStore({ + result: data, + query, + dataIdFromObject: () => 0, + }).toObject(), + ).toEqual(expStore.toObject()); + }); + describe('type escaping', () => { const dataIdFromObject = (object: any) => { if (object.__typename && object.id) { diff --git a/packages/apollo-cache-inmemory/src/writeToStore.ts b/packages/apollo-cache-inmemory/src/writeToStore.ts index 485c8549726..07274794f81 100644 --- a/packages/apollo-cache-inmemory/src/writeToStore.ts +++ b/packages/apollo-cache-inmemory/src/writeToStore.ts @@ -389,7 +389,7 @@ function writeFieldToStore({ ); } - if (semanticId) { + if (semanticId || (typeof semanticId === 'number' && semanticId === 0)) { valueDataId = semanticId; generated = false; } From 4cef9b9940e33ad841c848a5b935c6f33ba7cd13 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 20 Jul 2018 06:41:13 -0400 Subject: [PATCH 35/95] Changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 785d3085941..a7f8047f70a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,10 @@ - Add `__typename` and `id` properties to `dataIdFromObject` parameter (typescript) [@jfurler](https://github.com/jfurler) in [#3641](https://github.com/apollographql/apollo-client/pull/3641) +- Fixed an issue caused by `dataIdFromObject` considering returned 0 values to + be falsy, instead of being a valid ID, which lead to the store not being + updated properly in some cases. + [@hwillson](https://github.com/hwillson) in [#3711](https://github.com/apollographql/apollo-client/pull/3711) ## 2.3.5 (June 19, 2018) From 162b2bb42e25149ff2452ada6a2128585ece89a8 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 20 Jul 2018 06:50:20 -0400 Subject: [PATCH 36/95] Changelog update --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7f8047f70a..6310f81f33a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ [@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612) [@jinxac](https://github.com/jinxac) in [#3647](https://github.com/apollographql/apollo-client/pull/3647) [@abernix](https://github.com/abernix) in [#3705](https://github.com/apollographql/apollo-client/pull/3705) - [@dandv](https://github.com/dandv) in [#3703](https://github.com/apollographql/apollo-client/pull/3703) + [@dandv](https://github.com/dandv) in [#3703](https://github.com/apollographql/apollo-client/pull/3703) + [@hwillson](https://github.com/hwillson) in [#3580](https://github.com/apollographql/apollo-client/pull/3580) - Updated `graphql` `peerDependencies` to handle 14.x versions. [@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) - Add optional generic type params for variables on low level methods. From dcee389bd05ff7bb9b8aea676974713b3ec74b4b Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 20 Jul 2018 13:15:20 -0400 Subject: [PATCH 37/95] Slight code adjustments; Changelog updates; Ignore .snap in prettier --- .prettierignore | 1 + CHANGELOG.md | 217 +++++++++--------- .../__tests__/__snapshots__/config.ts.snap | 3 +- packages/apollo-boost/src/index.ts | 29 +-- 4 files changed, 127 insertions(+), 123 deletions(-) diff --git a/.prettierignore b/.prettierignore index a6c57f5fb2f..0f675f24227 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ *.json +*.snap diff --git a/CHANGELOG.md b/CHANGELOG.md index 6310f81f33a..6cfa7839e1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,45 +4,48 @@ ### Apollo Client (vNext) -- Documentation updates. - [@ananth99](https://github.com/ananth99) in [#3599](https://github.com/apollographql/apollo-client/pull/3599) - [@hwillson](https://github.com/hwillson) in [#3635](https://github.com/apollographql/apollo-client/pull/3635) - [@JakeDawkins](https://github.com/JakeDawkins) in [#3642](https://github.com/apollographql/apollo-client/pull/3642) - [@hwillson](https://github.com/hwillson) in [#3644](https://github.com/apollographql/apollo-client/pull/3644) - [@gbau](https://github.com/gbau) in [#3644](https://github.com/apollographql/apollo-client/pull/3600) - [@chentsulin](https://github.com/chentsulin) in [#3608](https://github.com/apollographql/apollo-client/pull/3608) - [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) - [@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612) - [@jinxac](https://github.com/jinxac) in [#3647](https://github.com/apollographql/apollo-client/pull/3647) - [@abernix](https://github.com/abernix) in [#3705](https://github.com/apollographql/apollo-client/pull/3705) - [@dandv](https://github.com/dandv) in [#3703](https://github.com/apollographql/apollo-client/pull/3703) - [@hwillson](https://github.com/hwillson) in [#3580](https://github.com/apollographql/apollo-client/pull/3580) -- Updated `graphql` `peerDependencies` to handle 14.x versions. +- Documentation updates.
+ [@ananth99](https://github.com/ananth99) in [#3599](https://github.com/apollographql/apollo-client/pull/3599)
+ [@hwillson](https://github.com/hwillson) in [#3635](https://github.com/apollographql/apollo-client/pull/3635)
+ [@JakeDawkins](https://github.com/JakeDawkins) in [#3642](https://github.com/apollographql/apollo-client/pull/3642)
+ [@hwillson](https://github.com/hwillson) in [#3644](https://github.com/apollographql/apollo-client/pull/3644)
+ [@gbau](https://github.com/gbau) in [#3644](https://github.com/apollographql/apollo-client/pull/3600)
+ [@chentsulin](https://github.com/chentsulin) in [#3608](https://github.com/apollographql/apollo-client/pull/3608)
+ [@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609)
+ [@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612)
+ [@jinxac](https://github.com/jinxac) in [#3647](https://github.com/apollographql/apollo-client/pull/3647)
+ [@abernix](https://github.com/abernix) in [#3705](https://github.com/apollographql/apollo-client/pull/3705)
+ [@dandv](https://github.com/dandv) in [#3703](https://github.com/apollographql/apollo-client/pull/3703)
+ [@hwillson](https://github.com/hwillson) in [#3580](https://github.com/apollographql/apollo-client/pull/3580)
+- Updated `graphql` `peerDependencies` to handle 14.x versions.
[@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) -- Add optional generic type params for variables on low level methods. +- Add optional generic type params for variables on low level methods.
[@mvestergaard](https://github.com/mvestergaard) in [#3588](https://github.com/apollographql/apollo-client/pull/3588) ### Apollo Boost (vNext) -- Allow `fetch` to be given as a configuration option to `ApolloBoost`. +- Allow `fetch` to be given as a configuration option to `ApolloBoost`.
[@mbaranovski](https://github.com/mbaranovski) in [#3590](https://github.com/apollographql/apollo-client/pull/3590) +- The `apollo-boost` `ApolloClient` constructor now warns about unsupported + options.
+ [@quentin-](https://github.com/quentin-) in [#3551](https://github.com/apollographql/apollo-client/pull/3551) ### Apollo GraphQL Anywhere (vNext) -- Add support for arrays to `graphql-anywhere`'s filter utility. +- Add support for arrays to `graphql-anywhere`'s filter utility.
[@jsweet314](https://github.com/jsweet314) in [#3591](https://github.com/apollographql/apollo-client/pull/3591) - Fix `Cannot convert object to primitive value` error that was showing up - when attempting to report a missing property on an object. + when attempting to report a missing property on an object.
[@benjie](https://github.com/benjie) in [#3618](https://github.com/apollographql/apollo-client/pull/3618) ### Apollo Cache In-Memory (vNext) - Add `__typename` and `id` properties to `dataIdFromObject` parameter - (typescript) + (typescript)
[@jfurler](https://github.com/jfurler) in [#3641](https://github.com/apollographql/apollo-client/pull/3641) - Fixed an issue caused by `dataIdFromObject` considering returned 0 values to be falsy, instead of being a valid ID, which lead to the store not being - updated properly in some cases. + updated properly in some cases.
[@hwillson](https://github.com/hwillson) in [#3711](https://github.com/apollographql/apollo-client/pull/3711) ## 2.3.5 (June 19, 2018) @@ -120,8 +123,8 @@ variables: `ObservableQuery` ([@excitement-engineer](https://github.com/excitement-engineer) in [#3140](https://github.com/apollographql/apollo-client/pull/3140)) - Added optional generics to cache manipulation methods (typescript). - ([@mvestergaard](https://github.com/mvestergaard) in [#3541](https://github.com/apollographql/apollo-client/pull/3541)) -- Typescript improvements. Created a new `QueryOptions` interface that + ([@mvestergaard](https://github.com/mvestergaard) in [#3541](https://github.com/apollographql/apollo-client/pull/3541)) +- Typescript improvements. Created a new `QueryOptions` interface that is now used by `ApolloClient.query` options, instead of the previous `WatchQueryOptions` interface. This helps reduce confusion (especially in the docs) that made it look like `ApolloClient.query` accepted @@ -130,88 +133,88 @@ ### Apollo Boost (0.1.8) -- Allow `cache` to be given as a configuration option to `ApolloBoost`. - ([@dandean](https://github.com/dandean) in [#3561](https://github.com/apollographql/apollo-client/pull/3561)) -- Allow `headers` and `credentials` to be passed in as configuration - parameters to the `apollo-boost` `ApolloClient` constructor. - ([@rzane](https://github.com/rzane) in [#3098](https://github.com/apollographql/apollo-client/pull/3098)) - -### Apollo Cache (1.1.10) - -- Added optional generics to cache manipulation methods (typescript). - ([@mvestergaard](https://github.com/mvestergaard) in [#3541](https://github.com/apollographql/apollo-client/pull/3541)) - -### Apollo Cache In-Memory (1.2.3) - -- Added optional generics to cache manipulation methods (typescript). - ([@mvestergaard](https://github.com/mvestergaard) in [#3541](https://github.com/apollographql/apollo-client/pull/3541)) -- Restore non-enumerability of `resultFields[ID_KEY]`. - ([@benjamn](https://github.com/benjamn) in [#3544](https://github.com/apollographql/apollo-client/pull/3544)) -- Cache query documents transformed by InMemoryCache. - ([@benjamn](https://github.com/benjamn) in [#3553](https://github.com/apollographql/apollo-client/pull/3553)) - -### Apollo Utilities (1.0.14) - -- Store key names generated by `getStoreKeyName` now leverage a more - deterministic approach to handling JSON based strings. This prevents store - key names from differing when using `args` like - `{ prop1: 'value1', prop2: 'value2' }` and - `{ prop2: 'value2', prop1: 'value1' }`. - ([@gdi2290](https://github.com/gdi2290) in [#2869](https://github.com/apollographql/apollo-client/pull/2869)) -- Avoid needless `hasOwnProperty` check in `deepFreeze`. - ([@benjamn](https://github.com/benjamn) in [#3545](https://github.com/apollographql/apollo-client/pull/3545)) - -### Apollo GraphQL Anywhere (4.1.12) - -- No new changes. - - -## 2.3.2 (May 29, 2018) - -### Apollo Client (2.3.2) - -- Fix SSR and `cache-and-network` fetch policy - ([@dastoori](https://github.com/dastoori) in [#3372](https://github.com/apollographql/apollo-client/pull/3372)) -- Fixed an issue where the `updateQuery` method passed to - `ObservableQuery.fetchMore` was receiving the original query variables, - instead of the new variables that it used to fetch more data. - ([@abhiaiyer91](https://github.com/abhiaiyer91) in [#3500](https://github.com/apollographql/apollo-client/pull/3500)) -- Fixed an issue involving `Object.setPrototypeOf()` not working on JSC - (Android), by instead setting the `prototype` of `this` manually. - ([@seklyza](https://github.com/seklyza) in [#3306](https://github.com/apollographql/apollo-client/pull/3306)) -- Added safeguards to make sure `QueryStore.initQuery` and - `QueryStore.markQueryResult` don't try to set the network status of a - `fetchMoreForQueryId` query, if it does not exist in the store. This was - happening when a query component was unmounted while a `fetchMore` was still - in flight. - ([@conrad-vanl](https://github.com/conrad-vanl) in [#3367](https://github.com/apollographql/apollo-client/pull/3367), [@doomsower](https://github.com/doomsower) in [#3469](https://github.com/apollographql/apollo-client/pull/3469)) - -### Apollo Boost (0.1.7) - -- Various internal code cleanup, tooling and dependency changes. - -### Apollo Cache (1.1.9) - -- Various internal code cleanup, tooling and dependency changes. - -### Apollo Cache In-Memory (1.2.2) - -- Fixed an issue that caused fragment only queries to sometimes fail. - ([@abhiaiyer91](https://github.com/abhiaiyer91) in [#3507](https://github.com/apollographql/apollo-client/pull/3507)) -- Fixed cache invalidation for inlined mixed types in union fields within - arrays. - ([@dferber90](https://github.com/dferber90) in [#3422](https://github.com/apollographql/apollo-client/pull/3422)) - -### Apollo Utilities (1.0.13) - -- Make `maybeDeepFreeze` a little more defensive, by always using - `Object.prototype.hasOwnProperty` (to avoid cases where the object being - frozen doesn't have its own `hasOwnProperty`). - ([@jorisroling](https://github.com/jorisroling) in [#3418](https://github.com/apollographql/apollo-client/pull/3418)) -- Remove certain small internal caches to prevent memory leaks when using SSR. - ([@brunorzn](https://github.com/brunorzn) in [#3444](https://github.com/apollographql/apollo-client/pull/3444)) - -### Apollo GraphQL Anywhere (4.1.11) - -- Source files are now excluded when publishing to npm. - ([@hwillson](https://github.com/hwillson) in [#3454](https://github.com/apollographql/apollo-client/pull/3454)) +- Allow `cache` to be given as a configuration option to `ApolloBoost`. + ([@dandean](https://github.com/dandean) in [#3561](https://github.com/apollographql/apollo-client/pull/3561)) +- Allow `headers` and `credentials` to be passed in as configuration + parameters to the `apollo-boost` `ApolloClient` constructor. + ([@rzane](https://github.com/rzane) in [#3098](https://github.com/apollographql/apollo-client/pull/3098)) + +### Apollo Cache (1.1.10) + +- Added optional generics to cache manipulation methods (typescript). + ([@mvestergaard](https://github.com/mvestergaard) in [#3541](https://github.com/apollographql/apollo-client/pull/3541)) + +### Apollo Cache In-Memory (1.2.3) + +- Added optional generics to cache manipulation methods (typescript). + ([@mvestergaard](https://github.com/mvestergaard) in [#3541](https://github.com/apollographql/apollo-client/pull/3541)) +- Restore non-enumerability of `resultFields[ID_KEY]`. + ([@benjamn](https://github.com/benjamn) in [#3544](https://github.com/apollographql/apollo-client/pull/3544)) +- Cache query documents transformed by InMemoryCache. + ([@benjamn](https://github.com/benjamn) in [#3553](https://github.com/apollographql/apollo-client/pull/3553)) + +### Apollo Utilities (1.0.14) + +- Store key names generated by `getStoreKeyName` now leverage a more + deterministic approach to handling JSON based strings. This prevents store + key names from differing when using `args` like + `{ prop1: 'value1', prop2: 'value2' }` and + `{ prop2: 'value2', prop1: 'value1' }`. + ([@gdi2290](https://github.com/gdi2290) in [#2869](https://github.com/apollographql/apollo-client/pull/2869)) +- Avoid needless `hasOwnProperty` check in `deepFreeze`. + ([@benjamn](https://github.com/benjamn) in [#3545](https://github.com/apollographql/apollo-client/pull/3545)) + +### Apollo GraphQL Anywhere (4.1.12) + +- No new changes. + + +## 2.3.2 (May 29, 2018) + +### Apollo Client (2.3.2) + +- Fix SSR and `cache-and-network` fetch policy + ([@dastoori](https://github.com/dastoori) in [#3372](https://github.com/apollographql/apollo-client/pull/3372)) +- Fixed an issue where the `updateQuery` method passed to + `ObservableQuery.fetchMore` was receiving the original query variables, + instead of the new variables that it used to fetch more data. + ([@abhiaiyer91](https://github.com/abhiaiyer91) in [#3500](https://github.com/apollographql/apollo-client/pull/3500)) +- Fixed an issue involving `Object.setPrototypeOf()` not working on JSC + (Android), by instead setting the `prototype` of `this` manually. + ([@seklyza](https://github.com/seklyza) in [#3306](https://github.com/apollographql/apollo-client/pull/3306)) +- Added safeguards to make sure `QueryStore.initQuery` and + `QueryStore.markQueryResult` don't try to set the network status of a + `fetchMoreForQueryId` query, if it does not exist in the store. This was + happening when a query component was unmounted while a `fetchMore` was still + in flight. + ([@conrad-vanl](https://github.com/conrad-vanl) in [#3367](https://github.com/apollographql/apollo-client/pull/3367), [@doomsower](https://github.com/doomsower) in [#3469](https://github.com/apollographql/apollo-client/pull/3469)) + +### Apollo Boost (0.1.7) + +- Various internal code cleanup, tooling and dependency changes. + +### Apollo Cache (1.1.9) + +- Various internal code cleanup, tooling and dependency changes. + +### Apollo Cache In-Memory (1.2.2) + +- Fixed an issue that caused fragment only queries to sometimes fail. + ([@abhiaiyer91](https://github.com/abhiaiyer91) in [#3507](https://github.com/apollographql/apollo-client/pull/3507)) +- Fixed cache invalidation for inlined mixed types in union fields within + arrays. + ([@dferber90](https://github.com/dferber90) in [#3422](https://github.com/apollographql/apollo-client/pull/3422)) + +### Apollo Utilities (1.0.13) + +- Make `maybeDeepFreeze` a little more defensive, by always using + `Object.prototype.hasOwnProperty` (to avoid cases where the object being + frozen doesn't have its own `hasOwnProperty`). + ([@jorisroling](https://github.com/jorisroling) in [#3418](https://github.com/apollographql/apollo-client/pull/3418)) +- Remove certain small internal caches to prevent memory leaks when using SSR. + ([@brunorzn](https://github.com/brunorzn) in [#3444](https://github.com/apollographql/apollo-client/pull/3444)) + +### Apollo GraphQL Anywhere (4.1.11) + +- Source files are now excluded when publishing to npm. + ([@hwillson](https://github.com/hwillson) in [#3454](https://github.com/apollographql/apollo-client/pull/3454)) diff --git a/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap b/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap index 42a9d762e2f..495a3b731db 100644 --- a/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap +++ b/packages/apollo-boost/src/__tests__/__snapshots__/config.ts.snap @@ -3,8 +3,7 @@ exports[`config warns about unsupported parameter 1`] = ` Array [ Array [ - "ApolloBoost was initialized with unsupported options: link -https://www.apollographql.com/docs/react/essentials/get-started.html#configuration", + "ApolloBoost was initialized with unsupported options: link", ], ] `; diff --git a/packages/apollo-boost/src/index.ts b/packages/apollo-boost/src/index.ts index 2e17e9fff33..3800d189b04 100644 --- a/packages/apollo-boost/src/index.ts +++ b/packages/apollo-boost/src/index.ts @@ -28,8 +28,16 @@ export interface PresetConfig { cache?: ApolloCache; } -// infer this list from the above interface -// using a typescript transform at compilation time. +// Yes, these are the exact same as the `PresetConfig` interface. We're +// defining these again so they can be used to verify that valid config +// options are being used in the `DefaultClient` constructor, for clients +// that aren't using Typescript. This duplication is unfortunate, and at +// some point can likely be adjusted so these items are inferred from +// the `PresetConfig` interface using a Typescript transform at compilation +// time. Unfortunately, TS transforms with rollup don't appear to be quite +// working properly, so this will have to be re-visited at some point. +// For now, when updating the properties of the `PresetConfig` interface, +// please also update this constant. const PRESET_CONFIG_KEYS = [ 'request', 'uri', @@ -43,24 +51,17 @@ const PRESET_CONFIG_KEYS = [ 'cache', ]; -function include(b: T, a: Array): boolean { - return a.indexOf(b) >= 0; -} - -function difference(a: Array, b: Array): Array { - return a.filter(x => !include(x, b)); -} - export default class DefaultClient extends ApolloClient { constructor(config: PresetConfig = {}) { if (config) { - const diff = difference(Object.keys(config), PRESET_CONFIG_KEYS); + const diff = Object.keys(config).filter( + key => PRESET_CONFIG_KEYS.indexOf(key) === -1, + ); if (diff.length > 0) { - // prettier-ignore console.warn( - `ApolloBoost was initialized with unsupported options: ${diff.join(' ')}\n` + - `https://www.apollographql.com/docs/react/essentials/get-started.html#configuration`, + 'ApolloBoost was initialized with unsupported options: ' + + `${diff.join(' ')}`, ); } } From 093b2b7207904d62689c1a8622cd37f7405191fe Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 20 Jul 2018 18:46:07 +0000 Subject: [PATCH 38/95] chore(deps): update dependency fetch-mock to v6.5.1 --- packages/apollo-boost/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apollo-boost/package.json b/packages/apollo-boost/package.json index 338c349b4b0..0257ff4c858 100644 --- a/packages/apollo-boost/package.json +++ b/packages/apollo-boost/package.json @@ -48,7 +48,7 @@ "@types/jest": "22.2.3", "apollo-utilities": "^1.0.16", "browserify": "15.2.0", - "fetch-mock": "6.5.0", + "fetch-mock": "6.5.1", "graphql": "0.13.2", "jest": "23.0.0", "lodash": "4.17.10", From 0780f65d883deb57ad0d56b862f1ec21eddae379 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 22 Jul 2018 06:14:29 +0000 Subject: [PATCH 39/95] chore(deps): update dependency rollup to v0.63.4 --- packages/apollo-cache-inmemory/package.json | 2 +- packages/apollo-cache/package.json | 2 +- packages/apollo-client/package.json | 2 +- packages/apollo-utilities/package.json | 2 +- packages/graphql-anywhere/package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/apollo-cache-inmemory/package.json b/packages/apollo-cache-inmemory/package.json index 3407c5c3180..82054629b6f 100644 --- a/packages/apollo-cache-inmemory/package.json +++ b/packages/apollo-cache-inmemory/package.json @@ -57,7 +57,7 @@ "jest": "23.0.0", "lodash": "4.17.10", "rimraf": "2.6.2", - "rollup": "0.62.0", + "rollup": "0.63.4", "ts-jest": "20.0.14", "tslint": "5.11.0", "typescript": "2.9.2", diff --git a/packages/apollo-cache/package.json b/packages/apollo-cache/package.json index 52f12acaee1..226113c1424 100644 --- a/packages/apollo-cache/package.json +++ b/packages/apollo-cache/package.json @@ -49,7 +49,7 @@ "graphql-tag": "2.9.2", "jest": "23.0.0", "rimraf": "2.6.2", - "rollup": "0.62.0", + "rollup": "0.63.4", "rollup-plugin-node-resolve": "3.3.0", "ts-jest": "20.0.14", "tslint": "5.11.0", diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index 73bd30efbec..58785277a11 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -77,7 +77,7 @@ "jest": "23.0.0", "lint-staged": "6.1.0", "lodash": "4.17.10", - "rollup": "0.62.0", + "rollup": "0.63.4", "rxjs": "6.2.2", "ts-jest": "20.0.14", "tslint": "5.11.0", diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index d678739c0ba..f5549a83a13 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -53,7 +53,7 @@ "jest": "23.0.0", "lodash": "4.17.10", "rimraf": "2.6.2", - "rollup": "0.62.0", + "rollup": "0.63.4", "ts-jest": "20.0.14", "tslint": "5.11.0", "typescript": "2.9.2", diff --git a/packages/graphql-anywhere/package.json b/packages/graphql-anywhere/package.json index c584ade2fcd..cec603ee1f5 100644 --- a/packages/graphql-anywhere/package.json +++ b/packages/graphql-anywhere/package.json @@ -55,7 +55,7 @@ "jest": "23.0.0", "react": "15.6.2", "react-dom": "15.6.2", - "rollup": "0.62.0", + "rollup": "0.63.4", "ts-jest": "20.0.14", "tslint": "5.11.0", "typescript": "2.9.2", From 78838f39b289411afeaf1fcfc6353522b94470e7 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 22 Jul 2018 07:34:25 +0000 Subject: [PATCH 40/95] chore(deps): update dependency flow-bin to v0.77.0 --- packages/apollo-client/package.json | 2 +- packages/apollo-utilities/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index 58785277a11..625ab22edc0 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -69,7 +69,7 @@ "browserify": "15.2.0", "bundlesize": "0.17.0", "danger": "1.1.0", - "flow-bin": "0.76.0", + "flow-bin": "0.77.0", "github": "12.1.0", "graphql": "14.0.0-rc.2", "graphql-tag": "2.9.2", diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index f5549a83a13..7ba34c99426 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -47,7 +47,7 @@ "@types/lodash": "4.14.112", "@types/node": "10.5.2", "browserify": "15.2.0", - "flow-bin": "0.76.0", + "flow-bin": "0.77.0", "graphql": "0.13.2", "graphql-tag": "2.9.2", "jest": "23.0.0", From 06d39749d7a00e0efeef91f18a563d823bcc883b Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 23 Jul 2018 13:41:07 -0400 Subject: [PATCH 41/95] Adjust refetch promises to run in parallel; Remove try-catch --- .../apollo-client/src/core/QueryManager.ts | 102 ++++++++++-------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/packages/apollo-client/src/core/QueryManager.ts b/packages/apollo-client/src/core/QueryManager.ts index ed59a206148..d5420216a52 100644 --- a/packages/apollo-client/src/core/QueryManager.ts +++ b/packages/apollo-client/src/core/QueryManager.ts @@ -192,6 +192,61 @@ export class QueryManager { ...context, optimisticResponse, }); + + const completeMutation = async () => { + if (error) { + this.mutationStore.markMutationError(mutationId, error); + } + + this.dataStore.markMutationComplete({ + mutationId, + optimisticResponse, + }); + + this.broadcastQueries(); + + // allow for conditional refetches + // XXX do we want to make this the only API one day? + if (typeof refetchQueries === 'function') { + refetchQueries = refetchQueries(storeResult as ExecutionResult); + } + + const refetchQueryPromises: Promise< + ApolloQueryResult[] | ApolloQueryResult<{}> + >[] = []; + + for (const refetchQuery of refetchQueries) { + if (typeof refetchQuery === 'string') { + const promise = this.refetchQueryByName(refetchQuery); + if (promise) { + refetchQueryPromises.push(promise); + } + continue; + } + + refetchQueryPromises.push( + this.query({ + query: refetchQuery.query, + variables: refetchQuery.variables, + fetchPolicy: 'network-only', + }), + ); + } + + await Promise.all(refetchQueryPromises); + + this.setQuery(mutationId, () => ({ document: undefined })); + if ( + errorPolicy === 'ignore' && + storeResult && + graphQLResultHasError(storeResult) + ) { + delete storeResult.errors; + } + + return storeResult as FetchResult; + }; + execute(this.link, operation).subscribe({ next: (result: ExecutionResult) => { if (graphQLResultHasError(result) && errorPolicy === 'none') { @@ -215,6 +270,7 @@ export class QueryManager { } storeResult = result as FetchResult; }, + error: (err: Error) => { this.mutationStore.markMutationError(mutationId, err); this.dataStore.markMutationComplete({ @@ -230,52 +286,8 @@ export class QueryManager { }), ); }, - complete: async () => { - try { - if (error) { - this.mutationStore.markMutationError(mutationId, error); - } - - this.dataStore.markMutationComplete({ - mutationId, - optimisticResponse, - }); - - this.broadcastQueries(); - - // allow for conditional refetches - // XXX do we want to make this the only API one day? - if (typeof refetchQueries === 'function') { - refetchQueries = refetchQueries(storeResult as ExecutionResult); - } - - for (const refetchQuery of refetchQueries) { - if (typeof refetchQuery === 'string') { - await this.refetchQueryByName(refetchQuery); - continue; - } - - await this.query({ - query: refetchQuery.query, - variables: refetchQuery.variables, - fetchPolicy: 'network-only', - }); - } - - this.setQuery(mutationId, () => ({ document: undefined })); - if ( - errorPolicy === 'ignore' && - storeResult && - graphQLResultHasError(storeResult) - ) { - delete storeResult.errors; - } - resolve(storeResult as FetchResult); - } catch (completionError) { - reject(completionError); - } - }, + complete: () => completeMutation().then(resolve, reject), }); }); } From 3a72e7ccdb111c789c95165166f791918bf75920 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 23 Jul 2018 14:16:45 -0400 Subject: [PATCH 42/95] Add `awaitRefetchQueries` option --- packages/apollo-client/src/core/QueryManager.ts | 5 ++++- packages/apollo-client/src/core/watchQueryOptions.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/apollo-client/src/core/QueryManager.ts b/packages/apollo-client/src/core/QueryManager.ts index d5420216a52..db6df9cb44e 100644 --- a/packages/apollo-client/src/core/QueryManager.ts +++ b/packages/apollo-client/src/core/QueryManager.ts @@ -122,6 +122,7 @@ export class QueryManager { optimisticResponse, updateQueries: updateQueriesByName, refetchQueries = [], + awaitRefetchQueries = false, update: updateWithProxyFn, errorPolicy = 'none', fetchPolicy, @@ -233,7 +234,9 @@ export class QueryManager { ); } - await Promise.all(refetchQueryPromises); + if (awaitRefetchQueries) { + await Promise.all(refetchQueryPromises); + } this.setQuery(mutationId, () => ({ document: undefined })); if ( diff --git a/packages/apollo-client/src/core/watchQueryOptions.ts b/packages/apollo-client/src/core/watchQueryOptions.ts index fdbffb7d0fc..addf271d707 100644 --- a/packages/apollo-client/src/core/watchQueryOptions.ts +++ b/packages/apollo-client/src/core/watchQueryOptions.ts @@ -180,6 +180,16 @@ export interface MutationBaseOptions< | ((result: ExecutionResult) => RefetchQueryDescription) | RefetchQueryDescription; + /** + * By default, `refetchQueries` does not wait for the refetched queries to + * be completed, before resolving the mutation `Promise`. This ensures that + * query refetching does not hold up mutation response handling (query + * refetching is handled asynchronously). Set `awaitRefetchQueries` to + * `true` if you would like to wait for the refetched queries to complete, + * before the mutation can be marked as resolved. + */ + awaitRefetchQueries?: boolean; + /** * A function which provides a {@link DataProxy} and the result of the * mutation to allow the user to update the store based on the results of the From 611b9fad73912c4496df6f204acd0478791f8b7b Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 23 Jul 2018 15:01:26 -0400 Subject: [PATCH 43/95] Fix existing functionality tests --- packages/apollo-client/src/core/QueryManager.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/apollo-client/src/core/QueryManager.ts b/packages/apollo-client/src/core/QueryManager.ts index db6df9cb44e..38428200832 100644 --- a/packages/apollo-client/src/core/QueryManager.ts +++ b/packages/apollo-client/src/core/QueryManager.ts @@ -206,6 +206,10 @@ export class QueryManager { this.broadcastQueries(); + if (error) { + throw error; + } + // allow for conditional refetches // XXX do we want to make this the only API one day? if (typeof refetchQueries === 'function') { From aead676dec72bf132fefc6ad1bbb6af4f19923a3 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 23 Jul 2018 15:03:02 -0400 Subject: [PATCH 44/95] Adjust `apollo-client` and `apollo-boost` bundle size max --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index dde6d4d11dd..3ef71a6fade 100644 --- a/package.json +++ b/package.json @@ -34,12 +34,12 @@ { "name": "apollo-client", "path": "./packages/apollo-client/lib/bundle.min.js", - "maxSize": "11.8 kB" + "maxSize": "12.5 kB" }, { "name": "apollo-boost", "path": "./packages/apollo-boost/lib/bundle.min.js", - "maxSize": "35 kB" + "maxSize": "36 kB" }, { "name": "apollo-utilities", From 4315a1a283503fb92a9c8e8c89c8395c63d6240d Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 23 Jul 2018 15:06:07 -0400 Subject: [PATCH 45/95] Changelog updates --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cfa7839e1f..d39a1243404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,11 @@ [@ivank](https://github.com/ivank) in [#3598](https://github.com/apollographql/apollo-client/pull/3598) - Add optional generic type params for variables on low level methods.
[@mvestergaard](https://github.com/mvestergaard) in [#3588](https://github.com/apollographql/apollo-client/pull/3588) +- Add a new `awaitRefetchQueries` config option to the Apollo Client + `mutate` function, that when set to `true` will wait for all + `refetchQueries` to be fully refetched, before resolving the mutation + call. `awaitRefetchQueries` is `false` by default.
+ [@jzimmek](https://github.com/jzimmek) in [#](https://github.com/apollographql/apollo-client/pull/3169) ### Apollo Boost (vNext) From 5e9a6ce862f86bc01381d6cb8c22f9fcf3522e0d Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 23 Jul 2018 15:35:56 -0400 Subject: [PATCH 46/95] New `awaitRefetchQueries` tests --- .../src/core/__tests__/QueryManager/index.ts | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/packages/apollo-client/src/core/__tests__/QueryManager/index.ts b/packages/apollo-client/src/core/__tests__/QueryManager/index.ts index 91ad49bdd87..1d8638e67be 100644 --- a/packages/apollo-client/src/core/__tests__/QueryManager/index.ts +++ b/packages/apollo-client/src/core/__tests__/QueryManager/index.ts @@ -3933,6 +3933,7 @@ describe('QueryManager', () => { }); }); }); + describe('refetchQueries', () => { const oldWarn = console.warn; let warned: any; @@ -4447,6 +4448,119 @@ describe('QueryManager', () => { done(); }); }); + + describe('awaitRefetchQueries', () => { + function awaitRefetchTest({ awaitRefetchQueries }) { + const query = gql` + query getAuthors($id: ID!) { + author(id: $id) { + firstName + lastName + } + } + `; + + const queryData = { + author: { + firstName: 'John', + lastName: 'Smith', + }, + }; + + const mutation = gql` + mutation changeAuthorName { + changeAuthorName(newName: "Jack Smith") { + firstName + lastName + } + } + `; + + const mutationData = { + changeAuthorName: { + firstName: 'Jack', + lastName: 'Smith', + }, + }; + + const secondReqData = { + author: { + firstName: 'Jane', + lastName: 'Johnson', + }, + }; + + const variables = { id: '1234' }; + + const queryManager = mockQueryManager( + { + request: { query, variables }, + result: { data: queryData }, + }, + { + request: { query: mutation }, + result: { data: mutationData }, + }, + { + request: { query, variables }, + result: { data: secondReqData }, + }, + ); + + const observable = queryManager.watchQuery({ + query, + variables, + notifyOnNetworkStatusChange: false, + }); + + let mutationComplete = false; + return observableToPromise( + { observable }, + result => { + expect(stripSymbols(result.data)).toEqual(queryData); + const mutateOptions = { + mutation, + refetchQueries: ['getAuthors'], + }; + if (awaitRefetchQueries) { + mutateOptions.awaitRefetchQueries = awaitRefetchQueries; + } + queryManager.mutate(mutateOptions).then(() => { + mutationComplete = true; + }); + }, + result => { + if (awaitRefetchQueries) { + expect(mutationComplete).not.toBeTruthy(); + } else { + expect(mutationComplete).toBeTruthy(); + } + expect(stripSymbols(observable.currentResult().data)).toEqual( + secondReqData, + ); + expect(stripSymbols(result.data)).toEqual(secondReqData); + }, + ); + } + + it( + 'should not wait for `refetchQueries` to complete before resolving ' + + 'the mutation, when `awaitRefetchQueries` is falsy', + () => { + awaitRefetchTest({ awaitRefetchQueries: undefined }); + awaitRefetchTest({ awaitRefetchQueries: false }); + }, + ); + + it( + 'should wait for `refetchQueries` to complete before resolving ' + + 'the mutation, when `awaitRefetchQueries` is `true`', + () => { + awaitRefetchTest({ awaitRefetchQueries: true }); + }, + ); + }); + describe('store watchers', () => { it('does not fill up the store on resolved queries', () => { const query1 = gql` From b2a7e44282373760531d742f27fe6adcf0d22c62 Mon Sep 17 00:00:00 2001 From: Victor Tortolero Date: Mon, 23 Jul 2018 17:19:32 -0500 Subject: [PATCH 47/95] docs: Add cache option info to apollo-boost get started Support for this option was added in [#3561](https://github.com/apollographql/apollo-client/pull/3561) but it was not documented yet. --- docs/source/essentials/get-started.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/essentials/get-started.md b/docs/source/essentials/get-started.md index 1b467193a1e..586c0b92ff8 100644 --- a/docs/source/essentials/get-started.md +++ b/docs/source/essentials/get-started.md @@ -163,6 +163,8 @@ Here are the options you can pass to the `ApolloClient` exported from `apollo-bo
Header key/value pairs to pass along with the request.
`fetch`: GlobalFetch['fetch']
A [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) compatible API for making a request.
+
`cache`: ApolloCache
+
A custom instance of ApolloCache to be used. The default value is `InMemoryCache` from `apollo-cache-inmemory`. This option is quite useful for using a custom cache with `apollo-cache-persist`.

Next steps

From dfa8188c60b43fde271130a2d62152707cc3dd3d Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 14:39:35 -0400 Subject: [PATCH 48/95] Add deprecation message to individual package changelogs --- packages/apollo-boost/CHANGELOG.md | 11 +++++++++-- packages/apollo-cache-inmemory/CHANGELOG.md | 9 ++++++++- packages/apollo-cache/CHANGELOG.md | 7 +++++++ packages/apollo-client/CHANGELOG.md | 13 ++++++++++--- packages/apollo-utilities/CHANGELOG.md | 7 +++++++ packages/graphql-anywhere/CHANGELOG.md | 9 ++++++++- 6 files changed, 49 insertions(+), 7 deletions(-) diff --git a/packages/apollo-boost/CHANGELOG.md b/packages/apollo-boost/CHANGELOG.md index 811ac4b6e52..f9f63cf7ecd 100644 --- a/packages/apollo-boost/CHANGELOG.md +++ b/packages/apollo-boost/CHANGELOG.md @@ -1,9 +1,16 @@ # CHANGELOG +---- + +**NOTE:** This changelog is no longer maintained. Changes are now tracked in +the top level [`CHANGELOG.md`](https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md). + +---- + ### vNext -- Allow `fetch` to be given as a configuration option to ApolloBoost. - [Issue #3578](https://github.com/apollographql/apollo-client/issues/3578) +- Allow `fetch` to be given as a configuration option to ApolloBoost. + [Issue #3578](https://github.com/apollographql/apollo-client/issues/3578) [PR #3590](https://github.com/apollographql/apollo-client/pull/3590) ### 0.1.10 diff --git a/packages/apollo-cache-inmemory/CHANGELOG.md b/packages/apollo-cache-inmemory/CHANGELOG.md index ff38059970f..a232a1f34b9 100644 --- a/packages/apollo-cache-inmemory/CHANGELOG.md +++ b/packages/apollo-cache-inmemory/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +---- + +**NOTE:** This changelog is no longer maintained. Changes are now tracked in +the top level [`CHANGELOG.md`](https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md). + +---- + ### 1.2.5 - No changes. @@ -21,7 +28,7 @@ - Fixed an issue that caused fragment only queries to sometimes fail. [Issue #3402](https://github.com/apollographql/apollo-client/issues/3402) - [PR #3507](https://github.com/apollographql/apollo-client/pull/3507) + [PR #3507](https://github.com/apollographql/apollo-client/pull/3507) - Fixed cache invalidation for inlined mixed types in union fields within arrays. [PR #3422](https://github.com/apollographql/apollo-client/pull/3422) diff --git a/packages/apollo-cache/CHANGELOG.md b/packages/apollo-cache/CHANGELOG.md index 284fdec03cb..c9adb0e2a3a 100644 --- a/packages/apollo-cache/CHANGELOG.md +++ b/packages/apollo-cache/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +---- + +**NOTE:** This changelog is no longer maintained. Changes are now tracked in +the top level [`CHANGELOG.md`](https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md). + +---- + ### 1.1.12 - No changes. diff --git a/packages/apollo-client/CHANGELOG.md b/packages/apollo-client/CHANGELOG.md index 108c5446a6c..89a929e4165 100644 --- a/packages/apollo-client/CHANGELOG.md +++ b/packages/apollo-client/CHANGELOG.md @@ -1,8 +1,15 @@ # CHANGELOG +---- + +**NOTE:** This changelog is no longer maintained. Changes are now tracked in +the top level [`CHANGELOG.md`](https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md). + +---- + ### vNext -- Updated `graphql` `peerDependencies` to handle 14.x versions. +- Updated `graphql` `peerDependencies` to handle 14.x versions. [PR #3598](https://github.com/apollographql/apollo-client/pull/3598) ### 2.3.5 @@ -27,7 +34,7 @@ [PR#3140](https://github.com/apollographql/apollo-client/pull/3140) - Added optional generics to cache manipulation methods (typescript). [PR #3541](https://github.com/apollographql/apollo-client/pull/3541) -- Typescript improvements. Created a new `QueryOptions` interface that +- Typescript improvements. Created a new `QueryOptions` interface that is now used by `ApolloClient.query` options, instead of the previous `WatchQueryOptions` interface. This helps reduce confusion (especially in the docs) that made it look like `ApolloClient.query` accepted @@ -49,7 +56,7 @@ (Android), by instead setting the `prototype` of `this` manually. [Issue #3236](https://github.com/apollographql/apollo-client/issues/3236) [PR #3306](https://github.com/apollographql/apollo-client/pull/3306) -- Added safeguards to make sure `QueryStore.initQuery` and +- Added safeguards to make sure `QueryStore.initQuery` and `QueryStore.markQueryResult` don't try to set the network status of a `fetchMoreForQueryId` query, if it does not exist in the store. This was happening when a query component was unmounted while a `fetchMore` was still diff --git a/packages/apollo-utilities/CHANGELOG.md b/packages/apollo-utilities/CHANGELOG.md index 35ffdbdf3e5..2cabb608182 100644 --- a/packages/apollo-utilities/CHANGELOG.md +++ b/packages/apollo-utilities/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +---- + +**NOTE:** This changelog is no longer maintained. Changes are now tracked in +the top level [`CHANGELOG.md`](https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md). + +---- + ### 1.0.16 - Removed unnecessary whitespace from error message diff --git a/packages/graphql-anywhere/CHANGELOG.md b/packages/graphql-anywhere/CHANGELOG.md index 3b7837936f1..79cf4786cde 100644 --- a/packages/graphql-anywhere/CHANGELOG.md +++ b/packages/graphql-anywhere/CHANGELOG.md @@ -1,8 +1,15 @@ # CHANGELOG +---- + +**NOTE:** This changelog is no longer maintained. Changes are now tracked in +the top level [`CHANGELOG.md`](https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md). + +---- + ### vNext -- Add support for arrays to `filter`. +- Add support for arrays to `filter`. [PR #3591](https://github.com/apollographql/apollo-client/pull/3591) ### 4.1.14 From eeaf10b6cd9238c406b115e5309e9c8f370da515 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 15:31:08 -0400 Subject: [PATCH 49/95] Replace `editor.rulers` 140 width with 80. --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1e6234170dd..d0e33774401 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ // Place your settings in this file to overwrite default and user settings. { "editor.tabSize": 2, - "editor.rulers": [140], + "editor.rulers": [80], "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, "files.exclude": { From 92e1b5b074bed7e88ce4e62240e02810d078dcae Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 15:36:08 -0400 Subject: [PATCH 50/95] Changelog updates, prepping for publish --- CHANGELOG.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d39a1243404..12217c29ff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ **Note:** This is a cumulative changelog that outlines all of the Apollo Client project child package changes that were bundled into a specific `apollo-client` release. -## vNext +## 2.3.6 (July 24, 2018) -### Apollo Client (vNext) +### Apollo Client (2.3.6) - Documentation updates.
[@ananth99](https://github.com/ananth99) in [#3599](https://github.com/apollographql/apollo-client/pull/3599)
@@ -27,7 +27,7 @@ call. `awaitRefetchQueries` is `false` by default.
[@jzimmek](https://github.com/jzimmek) in [#](https://github.com/apollographql/apollo-client/pull/3169) -### Apollo Boost (vNext) +### Apollo Boost (0.1.11) - Allow `fetch` to be given as a configuration option to `ApolloBoost`.
[@mbaranovski](https://github.com/mbaranovski) in [#3590](https://github.com/apollographql/apollo-client/pull/3590) @@ -35,15 +35,11 @@ options.
[@quentin-](https://github.com/quentin-) in [#3551](https://github.com/apollographql/apollo-client/pull/3551) -### Apollo GraphQL Anywhere (vNext) +### Apollo Cache (1.1.13) -- Add support for arrays to `graphql-anywhere`'s filter utility.
- [@jsweet314](https://github.com/jsweet314) in [#3591](https://github.com/apollographql/apollo-client/pull/3591) -- Fix `Cannot convert object to primitive value` error that was showing up - when attempting to report a missing property on an object.
- [@benjie](https://github.com/benjie) in [#3618](https://github.com/apollographql/apollo-client/pull/3618) +- No changes. -### Apollo Cache In-Memory (vNext) +### Apollo Cache In-Memory (1.2.6) - Add `__typename` and `id` properties to `dataIdFromObject` parameter (typescript)
@@ -53,6 +49,19 @@ updated properly in some cases.
[@hwillson](https://github.com/hwillson) in [#3711](https://github.com/apollographql/apollo-client/pull/3711) +### Apollo Utilities (1.0.17) + +- No changes. + +### Apollo GraphQL Anywhere (4.1.15) + +- Add support for arrays to `graphql-anywhere`'s filter utility.
+ [@jsweet314](https://github.com/jsweet314) in [#3591](https://github.com/apollographql/apollo-client/pull/3591) +- Fix `Cannot convert object to primitive value` error that was showing up + when attempting to report a missing property on an object.
+ [@benjie](https://github.com/benjie) in [#3618](https://github.com/apollographql/apollo-client/pull/3618) + + ## 2.3.5 (June 19, 2018) ### Apollo Client (2.3.5) From 47d3a02f30c417b47a9d665ff39f2d980b6b2810 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 15:37:02 -0400 Subject: [PATCH 51/95] Changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12217c29ff2..2f621fb835a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ `mutate` function, that when set to `true` will wait for all `refetchQueries` to be fully refetched, before resolving the mutation call. `awaitRefetchQueries` is `false` by default.
- [@jzimmek](https://github.com/jzimmek) in [#](https://github.com/apollographql/apollo-client/pull/3169) + [@jzimmek](https://github.com/jzimmek) in [#3169](https://github.com/apollographql/apollo-client/pull/3169) ### Apollo Boost (0.1.11) From b9fb72f252a6c13f430d26acb8bab6ce44ae89ce Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 15:38:48 -0400 Subject: [PATCH 52/95] chore: Publish - apollo-boost@0.1.11 - apollo-cache-inmemory@1.2.6 - apollo-cache@1.1.13 - apollo-client@2.3.6 - apollo-utilities@1.0.17 - graphql-anywhere@4.1.15 --- packages/apollo-boost/package.json | 10 +++++----- packages/apollo-cache-inmemory/package.json | 8 ++++---- packages/apollo-cache/package.json | 4 ++-- packages/apollo-client/package.json | 8 ++++---- packages/apollo-utilities/package.json | 2 +- packages/graphql-anywhere/package.json | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/apollo-boost/package.json b/packages/apollo-boost/package.json index 0257ff4c858..e2e4a5b76bd 100644 --- a/packages/apollo-boost/package.json +++ b/packages/apollo-boost/package.json @@ -1,6 +1,6 @@ { "name": "apollo-boost", - "version": "0.1.10", + "version": "0.1.11", "description": "The easiest way to get started with Apollo Client", "author": "Peggy Rayzis ", "contributors": [ @@ -34,9 +34,9 @@ "filesize": "npm run build && npm run build:browser" }, "dependencies": { - "apollo-cache": "^1.1.12", - "apollo-cache-inmemory": "^1.2.5", - "apollo-client": "^2.3.5", + "apollo-cache": "^1.1.13", + "apollo-cache-inmemory": "^1.2.6", + "apollo-client": "^2.3.6", "apollo-link": "^1.0.6", "apollo-link-error": "^1.0.3", "apollo-link-http": "^1.3.1", @@ -46,7 +46,7 @@ "devDependencies": { "@types/graphql": "0.12.7", "@types/jest": "22.2.3", - "apollo-utilities": "^1.0.16", + "apollo-utilities": "^1.0.17", "browserify": "15.2.0", "fetch-mock": "6.5.1", "graphql": "0.13.2", diff --git a/packages/apollo-cache-inmemory/package.json b/packages/apollo-cache-inmemory/package.json index 82054629b6f..92cc4a83340 100644 --- a/packages/apollo-cache-inmemory/package.json +++ b/packages/apollo-cache-inmemory/package.json @@ -1,6 +1,6 @@ { "name": "apollo-cache-inmemory", - "version": "1.2.5", + "version": "1.2.6", "description": "Core abstract of Caching layer for Apollo Client", "author": "James Baxley ", "contributors": [ @@ -40,9 +40,9 @@ "filesize": "npm run build:browser" }, "dependencies": { - "apollo-cache": "^1.1.12", - "apollo-utilities": "^1.0.16", - "graphql-anywhere": "^4.1.14" + "apollo-cache": "^1.1.13", + "apollo-utilities": "^1.0.17", + "graphql-anywhere": "^4.1.15" }, "peerDependencies": { "graphql": "0.11.7 || ^0.12.0 || ^0.13.0" diff --git a/packages/apollo-cache/package.json b/packages/apollo-cache/package.json index 226113c1424..ee0593af10e 100644 --- a/packages/apollo-cache/package.json +++ b/packages/apollo-cache/package.json @@ -1,6 +1,6 @@ { "name": "apollo-cache", - "version": "1.1.12", + "version": "1.1.13", "description": "Core abstract of Caching layer for Apollo Client", "author": "James Baxley ", "contributors": [ @@ -39,7 +39,7 @@ "filesize": "npm run build && npm run build:browser" }, "dependencies": { - "apollo-utilities": "^1.0.16" + "apollo-utilities": "^1.0.17" }, "devDependencies": { "@types/graphql": "0.12.7", diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index 625ab22edc0..39881581d39 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -1,7 +1,7 @@ { "name": "apollo-client", "private": true, - "version": "2.3.5", + "version": "2.3.6", "description": "A simple yet functional GraphQL client.", "main": "./lib/bundle.umd.js", "module": "./lib/index.js", @@ -47,10 +47,10 @@ "license": "MIT", "dependencies": { "@types/zen-observable": "^0.8.0", - "apollo-cache": "^1.1.12", + "apollo-cache": "^1.1.13", "apollo-link": "^1.0.0", "apollo-link-dedup": "^1.0.0", - "apollo-utilities": "^1.0.16", + "apollo-utilities": "^1.0.17", "symbol-observable": "^1.0.2", "zen-observable": "^0.8.0" }, @@ -64,7 +64,7 @@ "@types/jest": "22.2.3", "@types/lodash": "4.14.112", "@types/node": "10.5.2", - "apollo-cache-inmemory": "^1.2.5", + "apollo-cache-inmemory": "^1.2.6", "benchmark": "2.1.4", "browserify": "15.2.0", "bundlesize": "0.17.0", diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index 7ba34c99426..091bde9191e 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -1,6 +1,6 @@ { "name": "apollo-utilities", - "version": "1.0.16", + "version": "1.0.17", "description": "Utilities for working with GraphQL ASTs", "author": "James Baxley ", "contributors": [ diff --git a/packages/graphql-anywhere/package.json b/packages/graphql-anywhere/package.json index cec603ee1f5..c269808d72c 100644 --- a/packages/graphql-anywhere/package.json +++ b/packages/graphql-anywhere/package.json @@ -1,6 +1,6 @@ { "name": "graphql-anywhere", - "version": "4.1.14", + "version": "4.1.15", "description": "Run GraphQL queries with no schema and just one resolver", "main": "./lib/bundle.umd.js", "module": "./lib/index.js", @@ -39,7 +39,7 @@ ], "license": "MIT", "dependencies": { - "apollo-utilities": "^1.0.16" + "apollo-utilities": "^1.0.17" }, "devDependencies": { "@types/graphql": "0.12.7", From 33e4ca6024037ea7225d62bbd7527e5fcd7cfd66 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 17:47:50 -0400 Subject: [PATCH 53/95] Fix broken related guide `State Management` link --- docs/_config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_config.yml b/docs/_config.yml index b30976afb39..42c34ebd73e 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -54,7 +54,7 @@ sidebar_categories: - recipes/recompose Related Guides: - title: State Management - href: https://www.apollographql.com/docs/guides/state-mgmt.html + href: https://www.apollographql.com/docs/guides/state-management.html - title: Testing React Components href: https://www.apollographql.com/docs/guides/testing-react-components.html - title: Schema Design From 91a67d60e4b640534e17493504dce0b8bb42ce33 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 21:20:48 -0400 Subject: [PATCH 54/95] Fix broken `getQueryWithPreviousResult` return type declaration Release 2.3.6 broke Typescript compilation. `QueryManager`'s `getQueryWithPreviousResult` method included an invalid `variables` return type in the auto-generated `core/QueryManager.d.ts` declaration file. The type definition had a locally referenced path, that appears to have been caused by the typescript compiler getting confused at compile/publish time. `getQueryWithPreviousResult` return types are now excplicity identified, which helps Typescript avoid the local type reference. For more details, see https://github.com/apollographql/apollo-client/issues/3729. Fixes #3729. --- CHANGELOG.md | 35 +++++++++++++++++++ .../apollo-client/src/core/QueryManager.ts | 13 +++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f621fb835a..7b9a2b31adc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ **Note:** This is a cumulative changelog that outlines all of the Apollo Client project child package changes that were bundled into a specific `apollo-client` release. +## 2.3.7 (July 24, 2018) + +### Apollo Client (2.3.7) + +- Release 2.3.6 broke Typescript compilation. `QueryManager`'s + `getQueryWithPreviousResult` method included an invalid `variables` return + type in the auto-generated `core/QueryManager.d.ts` declaration file. The + type definition had a locally referenced path, that appears to have been + caused by the typescript compiler getting confused at compile/publish time. + `getQueryWithPreviousResult` return types are now excplicity identified, + which helps Typescript avoid the local type reference. For more details, + see https://github.com/apollographql/apollo-client/issues/3729. + [@hwillson](https://github.com/hwillson) in [#](https://github.com/apollographql/apollo-client/pull/) + +### Apollo Boost (0.1.12) + +- No changes. + +### Apollo Cache (1.1.14) + +- No changes. + +### Apollo Cache In-Memory (1.2.7) + +- No changes. + +### Apollo Utilities (1.0.18) + +- No changes. + +### Apollo GraphQL Anywhere (4.1.16) + +- No changes. + + ## 2.3.6 (July 24, 2018) ### Apollo Client (2.3.6) diff --git a/packages/apollo-client/src/core/QueryManager.ts b/packages/apollo-client/src/core/QueryManager.ts index 38428200832..ff0fe886912 100644 --- a/packages/apollo-client/src/core/QueryManager.ts +++ b/packages/apollo-client/src/core/QueryManager.ts @@ -33,7 +33,12 @@ import { } from './watchQueryOptions'; import { ObservableQuery } from './ObservableQuery'; import { NetworkStatus, isNetworkRequestInFlight } from './networkStatus'; -import { QueryListener, ApolloQueryResult, FetchType } from './types'; +import { + QueryListener, + ApolloQueryResult, + FetchType, + OperationVariables, +} from './types'; import { graphQLResultHasError } from 'apollo-utilities'; export interface QueryInfo { @@ -1005,7 +1010,11 @@ export class QueryManager { public getQueryWithPreviousResult( queryIdOrObservable: string | ObservableQuery, - ) { + ): { + previousResult: any; + variables: OperationVariables | undefined; + document: DocumentNode; + } { let observableQuery: ObservableQuery; if (typeof queryIdOrObservable === 'string') { const { observableQuery: foundObserveableQuery } = this.getQuery( From 21f436a15a5b54c163d623180608a5809e93bfec Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 21:24:12 -0400 Subject: [PATCH 55/95] Changelog update with PR link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b9a2b31adc..3048276e310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ `getQueryWithPreviousResult` return types are now excplicity identified, which helps Typescript avoid the local type reference. For more details, see https://github.com/apollographql/apollo-client/issues/3729. - [@hwillson](https://github.com/hwillson) in [#](https://github.com/apollographql/apollo-client/pull/) + [@hwillson](https://github.com/hwillson) in [#3731](https://github.com/apollographql/apollo-client/pull/3731) ### Apollo Boost (0.1.12) From 11319da29a619945d3d532f2494983581c960a42 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 21:35:12 -0400 Subject: [PATCH 56/95] chore: Publish - apollo-boost@0.1.12 - apollo-client@2.3.7 --- packages/apollo-boost/package.json | 4 ++-- packages/apollo-client/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/apollo-boost/package.json b/packages/apollo-boost/package.json index e2e4a5b76bd..f67f130f14d 100644 --- a/packages/apollo-boost/package.json +++ b/packages/apollo-boost/package.json @@ -1,6 +1,6 @@ { "name": "apollo-boost", - "version": "0.1.11", + "version": "0.1.12", "description": "The easiest way to get started with Apollo Client", "author": "Peggy Rayzis ", "contributors": [ @@ -36,7 +36,7 @@ "dependencies": { "apollo-cache": "^1.1.13", "apollo-cache-inmemory": "^1.2.6", - "apollo-client": "^2.3.6", + "apollo-client": "^2.3.7", "apollo-link": "^1.0.6", "apollo-link-error": "^1.0.3", "apollo-link-http": "^1.3.1", diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index 39881581d39..b1e26f0dff8 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -1,7 +1,7 @@ { "name": "apollo-client", "private": true, - "version": "2.3.6", + "version": "2.3.7", "description": "A simple yet functional GraphQL client.", "main": "./lib/bundle.umd.js", "module": "./lib/index.js", From e1f3a04c473ed004319ffb430ed3071773f19f27 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Tue, 24 Jul 2018 21:38:43 -0400 Subject: [PATCH 57/95] Removed packages from recent release that were not published --- CHANGELOG.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3048276e310..e84ae906ae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,22 +18,6 @@ - No changes. -### Apollo Cache (1.1.14) - -- No changes. - -### Apollo Cache In-Memory (1.2.7) - -- No changes. - -### Apollo Utilities (1.0.18) - -- No changes. - -### Apollo GraphQL Anywhere (4.1.16) - -- No changes. - ## 2.3.6 (July 24, 2018) From ea9338d0ab3389617c556cabcfa0e53689b2ccf8 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 25 Jul 2018 03:04:35 +0000 Subject: [PATCH 58/95] chore(deps): update dependency @types/lodash to v4.14.113 --- packages/apollo-cache-inmemory/package.json | 2 +- packages/apollo-client/package.json | 2 +- packages/apollo-utilities/package.json | 2 +- packages/graphql-anywhere/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/apollo-cache-inmemory/package.json b/packages/apollo-cache-inmemory/package.json index 92cc4a83340..02f258defbe 100644 --- a/packages/apollo-cache-inmemory/package.json +++ b/packages/apollo-cache-inmemory/package.json @@ -50,7 +50,7 @@ "devDependencies": { "@types/graphql": "0.12.7", "@types/jest": "22.2.3", - "@types/lodash": "4.14.112", + "@types/lodash": "4.14.113", "browserify": "15.2.0", "graphql": "0.13.2", "graphql-tag": "2.9.2", diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index b1e26f0dff8..742df3e958f 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -62,7 +62,7 @@ "@types/graphql": "0.12.7", "@types/isomorphic-fetch": "0.0.34", "@types/jest": "22.2.3", - "@types/lodash": "4.14.112", + "@types/lodash": "4.14.113", "@types/node": "10.5.2", "apollo-cache-inmemory": "^1.2.6", "benchmark": "2.1.4", diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index 091bde9191e..2b23511111a 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -44,7 +44,7 @@ "devDependencies": { "@types/graphql": "0.12.7", "@types/jest": "22.2.3", - "@types/lodash": "4.14.112", + "@types/lodash": "4.14.113", "@types/node": "10.5.2", "browserify": "15.2.0", "flow-bin": "0.77.0", diff --git a/packages/graphql-anywhere/package.json b/packages/graphql-anywhere/package.json index c269808d72c..66f040b7cb1 100644 --- a/packages/graphql-anywhere/package.json +++ b/packages/graphql-anywhere/package.json @@ -45,7 +45,7 @@ "@types/graphql": "0.12.7", "@types/isomorphic-fetch": "0.0.34", "@types/jest": "22.2.3", - "@types/lodash": "4.14.112", + "@types/lodash": "4.14.113", "@types/node": "10.5.2", "@types/react": "16.0.34", "@types/react-dom": "16.0.4", From 2f3603496ea0de39b0695f64cf5a4968bfef4a57 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 26 Jul 2018 04:37:49 +0000 Subject: [PATCH 59/95] chore(deps): update dependency fetch-mock to v6.5.2 --- packages/apollo-boost/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apollo-boost/package.json b/packages/apollo-boost/package.json index f67f130f14d..dfd1fdb8807 100644 --- a/packages/apollo-boost/package.json +++ b/packages/apollo-boost/package.json @@ -48,7 +48,7 @@ "@types/jest": "22.2.3", "apollo-utilities": "^1.0.17", "browserify": "15.2.0", - "fetch-mock": "6.5.1", + "fetch-mock": "6.5.2", "graphql": "0.13.2", "jest": "23.0.0", "lodash": "4.17.10", From 7ea28b4243903dfa849552ae0fb86f83a6c982c9 Mon Sep 17 00:00:00 2001 From: unicodeveloper Date: Thu, 26 Jul 2018 17:31:13 +0200 Subject: [PATCH 60/95] Add defer support --- docs/source/features/defer-support.md | 206 ++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 docs/source/features/defer-support.md diff --git a/docs/source/features/defer-support.md b/docs/source/features/defer-support.md new file mode 100644 index 00000000000..61537ba0ad4 --- /dev/null +++ b/docs/source/features/defer-support.md @@ -0,0 +1,206 @@ +--- +title: Deferred Queries +description: Optimize data loading with the @defer directive +--- + +

Setting up

+ +Note: `@defer` support is an experimental feature that is only available in the alpha preview of Apollo Server and Apollo Client. + +- On the server: + + ``` + npm install apollo-server@alpha + ``` + +- On the client, if you are using Apollo Boost: + ``` + npm install apollo-boost@alpha react-apollo@alpha + ``` + Or if you are using Apollo Client: + ``` + npm install apollo-client@alpha apollo-cache-inmemory@alpha apollo-link-http@alpha apollo-link-error apollo-link + ``` + +

The `@defer` Directive

+ +Many applications that use Apollo fetch data from a variety of microservices, which may each have varying latencies and cache characteristics. Apollo comes with a built-in directive for deferring parts of your GraphQL query in a declarative way, so that fields that take a long time to resolve do not need to slow down your entire query. + +There are 3 main reasons why you may want to defer a field: + +1. **Field is expensive to load.** This includes private data that is not cached (like user progress), or information that requires more computation on the backend (like calculating price quotes on Airbnb). +2. **Field is not on the critical path for interactivity.** This includes the comments section of a story, or the number of claps received. +3. **Field is expensive to send.** Even if the field may resolve quickly (ready to send back), users might still choose to defer it if the cost of transport is too expensive. + +As an example, take a look at the following query that populates a NewsFeed page: + +```graphql +query NewsFeed { + newsFeed { + stories { + text + comments { + text + } + } + recommendedForYou { + story { + text + comments { + text + } + } + matchScore + } + } +} +``` + +It is likely that the time needed for different fields in a query to resolve are significantly different. `stories` is highly public data that we can cache in CDNs (fast), while `recommendedForYou` is personalized and may need to be computed for every user (slooow). Also, we might not need `comments` to be displayed immediately, so slowing down our query to wait for them to be fetched is not the best idea. + +

How to use `@defer`

+ +We can optimize the above query with `@defer`: + +```graphql +query NewsFeed { + newsFeed { + stories { + text + comments @defer { + text + } + } + recommendedForYou @defer { + story { + text + comments @defer { + text + } + } + matchScore + } + } +} +``` + +Once you have added `@defer`, Apollo Server will return an initial response without waiting for deferred fields to resolve, using `null` as placeholders for them. Then, it streams patches for each deferred field asynchronously as they resolve. + +```json +// Initial response +{ + "data": { + "newsFeed": { + "stories": [{ "text": "...", "comments": null }], + "recommendedForYou": null + } + } +} +``` + +```json +// Patch for "recommendedForYou" +{ + "path": ["newsFeed", "recommendedForYou"], + "data": [ + { + "story": { + "text": "..." + }, + "matchScore": 99 + } + ] +} +``` + +```json +// Patch for "comments", sent for each story +{ + "path": ["newsFeed", "stories", 1, "comments"], + "data": [ + { + "text": "..." + } + ] +} +``` + +If an error is thrown within a resolver, the error gets sent along with its closest deferred parent, and is merged with the `graphQLErrors` array on the client. + +```json +// Patch for "comments" if there is an error +{ + "path": ["newsFeed", "stories", 1, "comments"], + "data": null, + "errors": [ + { + "message": "Failed to fetch comments" + } + ] +} +``` + +

Distinguishing between "pending" and "null"

+ +You may have noticed that deferred fields are returned as `null` in the initial response. So how can we know which fields are pending so that we can show some loading indicator? To deal with that, Apollo Client now exposes field-level loading information in a new property called `loadingState` that you can check for in your UI components. The shape of `loadingState` mirrors that of your data. For example, if `data.newsFeed.stories` is ready, `loadingState.newsFeed.stories` will be `true`. + +You can use it in a React component like this: + +```jsx harmony + + {({ loading, error, data, loadingState }) => { + if (loading) return 'loading...'; + return loadingState.newsFeed.recommendedForYou + ? data.newsFeed.recommendedForYou + ? data /* render component here */ + : 'No recommended content' + : 'Loading recommended content'; + }} + +``` + +

Where is `@defer` allowed?

+ +- `@defer` can be applied on any `FIELD` of a `Query` operation. It also takes an optional argument `if`, that is a `boolean` controlling whether it is active, similar to `@include`. + +- `@include` and `@skip` take precedence over `@defer`. + +- Mutations: Not supported. + +- Non-Nullable Types: Not allowed and will throw a validation error. This is because deferred fields are returned as `null` in the initial response. Deferring non-nullable types may also lead to unexpected behavior when errors occur, since errors will propagate up to the nearest nullable parent as per the GraphQL spec. We want to avoid letting errors on deferred fields clobber the initial data that was loaded already. + +- Nesting: `@defer` can be nested arbitrarily. For example, we can defer a list type, and defer a field on an object in the list. During execution, we ensure that the patch for a parent field will be sent before its children, even if the child object resolves first. This will simplify the logic for merging patches. + +- GraphQL fragments: Supported. If there are multiple declarations of a field within the query, **all** of them have to contain `@defer` for the field to be deferred. This could happen if we have use a fragment like this: + + ```graphql + fragment StoryDetail on Story { + id + text + } + query { + newsFeed { + stories { + text @defer + ...StoryDetail + } + } + } + ``` + In this case, `text` will not be deferred since `@defer` was not applied in the fragment definition. + + A common pattern around fragments is to bind it to a component and reuse them across different parts of your UI. This is why it would be ideal to make sure that the `@defer` behavior of fields in a fragment is not overridden. + +

Transport

+ +There is no additional setup for the transport required to use `@defer`. By default, deferred responses are transmitted using [Multipart HTTP](https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html). For browsers that do not support the [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) API used to read streaming responses, we will just fallback to normal query execution ignoring `@defer`. + +

Performance Considerations

+ +`@defer` is one of those features that work best if used in moderation. If it is used too granularly (on many nested fields), the overhead of performing patching and re-rendering could be worse than just waiting for the full query to resolve. Try to limit `@defer` to fields that take a significantly longer time to load. This is super easy to figure out if you have Apollo Engine set up! + +

Use with other GraphQL servers

+ +If you are sending queries to a GraphQL server that does not support `@defer`, it is likely that the `@defer` directive is simply ignored, or a GraphQL validation error is thrown. + +If you would want to implement a GraphQL server that is able to interoperate with Apollo Client, please look at the documentation [here](https://github.com/apollographql/apollo-server/blob/defer-support/docs/source/defer-support.md). \ No newline at end of file From 9f9740a2d95dd7ef93643034fb841e18b93b3a5b Mon Sep 17 00:00:00 2001 From: unicodeveloper Date: Thu, 26 Jul 2018 17:31:57 +0200 Subject: [PATCH 61/95] Add defer support to sidebar --- docs/_config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_config.yml b/docs/_config.yml index 42c34ebd73e..23fe70a42e5 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -37,6 +37,7 @@ sidebar_categories: - features/server-side-rendering - features/performance - features/developer-tooling + - features/defer-support Advanced: - advanced/boost-migration - advanced/subscriptions From 1ae788d8d00ea546b1ff112b1010e0d8e5519673 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 26 Jul 2018 21:02:30 -0400 Subject: [PATCH 62/95] Adjust `graphql` peer dep to cover explicit minor ranges Since the ^ operator only covers any minor version if the major version is not 0 (since a major version if technically considered development by semver 2), the current ^0.11.0 || ^14.0.0 graphql range doesn't cover 0.12.* or 0.13.*. Fixes #3737. --- packages/apollo-client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index 742df3e958f..a0db8394e3c 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -55,7 +55,7 @@ "zen-observable": "^0.8.0" }, "peerDependencies": { - "graphql": "^0.11.0 || ^14.0.0" + "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" }, "devDependencies": { "@types/benchmark": "1.0.31", From 7067ffbb990842c00e2c4341e1dd5d5bd28cb0e3 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 26 Jul 2018 21:13:30 -0400 Subject: [PATCH 63/95] Changelog update --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e84ae906ae3..7c3e53a55a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ **Note:** This is a cumulative changelog that outlines all of the Apollo Client project child package changes that were bundled into a specific `apollo-client` release. +## 2.3.8 (July 26, 2018) + +### Apollo Client (2.3.7) + +- Adjusted the `graphql` peer dependency to cover explicit minor ranges. + Since the ^ operator only covers any minor version if the major version + is not 0 (since a major version of 0 is technically considered development by + semver 2), the current ^0.11.0 || ^14.0.0 graphql range doesn't cover + 0.12.* or 0.13.*. This fixes the `apollo-client@X has incorrect peer + dependency "graphql@^0.11.0 || ^14.0.0"` errors that people might have + seen using `graphql` 0.12.x or 0.13.x. + [@hwillson](https://github.com/hwillson) in [#3746](https://github.com/apollographql/apollo-client/pull/3746) + + ## 2.3.7 (July 24, 2018) ### Apollo Client (2.3.7) From cf15592d6706b617c6a39d4f67a219c50828898b Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 26 Jul 2018 21:16:03 -0400 Subject: [PATCH 64/95] Changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c3e53a55a4..601fb786d10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ semver 2), the current ^0.11.0 || ^14.0.0 graphql range doesn't cover 0.12.* or 0.13.*. This fixes the `apollo-client@X has incorrect peer dependency "graphql@^0.11.0 || ^14.0.0"` errors that people might have - seen using `graphql` 0.12.x or 0.13.x. + seen using `graphql` 0.12.x or 0.13.x.
[@hwillson](https://github.com/hwillson) in [#3746](https://github.com/apollographql/apollo-client/pull/3746) From 390692b8c8d0c6de724f27969a748d97ad22353a Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 26 Jul 2018 21:16:52 -0400 Subject: [PATCH 65/95] Changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 601fb786d10..524ed21ceb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.3.8 (July 26, 2018) -### Apollo Client (2.3.7) +### Apollo Client (vNext) - Adjusted the `graphql` peer dependency to cover explicit minor ranges. Since the ^ operator only covers any minor version if the major version From 863d4f3b6b1fda5b21350a009c6b810e61dd91f1 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Thu, 26 Jul 2018 21:18:00 -0400 Subject: [PATCH 66/95] Changelog update --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 524ed21ceb9..cbbec3dadd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ **Note:** This is a cumulative changelog that outlines all of the Apollo Client project child package changes that were bundled into a specific `apollo-client` release. -## 2.3.8 (July 26, 2018) +## vNext ### Apollo Client (vNext) @@ -25,7 +25,7 @@ caused by the typescript compiler getting confused at compile/publish time. `getQueryWithPreviousResult` return types are now excplicity identified, which helps Typescript avoid the local type reference. For more details, - see https://github.com/apollographql/apollo-client/issues/3729. + see https://github.com/apollographql/apollo-client/issues/3729.
[@hwillson](https://github.com/hwillson) in [#3731](https://github.com/apollographql/apollo-client/pull/3731) ### Apollo Boost (0.1.12) From e25c1ca2c61126c5c47ea0ab4b41d2dfd8a2b8e9 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 27 Jul 2018 10:16:28 -0400 Subject: [PATCH 67/95] Fix a few implicit-any type warnings in ObservableQuery.ts. --- packages/apollo-client/src/core/ObservableQuery.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/apollo-client/src/core/ObservableQuery.ts b/packages/apollo-client/src/core/ObservableQuery.ts index 3df67f34a35..f68f917411a 100644 --- a/packages/apollo-client/src/core/ObservableQuery.ts +++ b/packages/apollo-client/src/core/ObservableQuery.ts @@ -120,7 +120,7 @@ export class ObservableQuery< return new Promise((resolve, reject) => { let subscription: Subscription; const observer: Observer> = { - next(result) { + next(result: ApolloQueryResult) { resolve(result); // Stop the query within the QueryManager if we can before @@ -141,7 +141,7 @@ export class ObservableQuery< subscription.unsubscribe(); }, 0); }, - error(error) { + error(error: any) { reject(error); }, }; @@ -339,29 +339,27 @@ export class ObservableQuery< // XXX the subscription variables are separate from the query variables. // if you want to update subscription variables, right now you have to do that separately, // and you can only do it by stopping the subscription and then subscribing again with new variables. - public subscribeToMore( - options: SubscribeToMoreOptions, - ): () => void { + public subscribeToMore(options: SubscribeToMoreOptions) { const subscription = this.queryManager .startGraphQLSubscription({ query: options.document, variables: options.variables, }) .subscribe({ - next: data => { + next: (subscriptionData: { data: TData }) => { if (options.updateQuery) { this.updateQuery((previous, { variables }) => (options.updateQuery as UpdateQueryFn)( previous, { - subscriptionData: data as { data: TData }, + subscriptionData, variables, }, ), ); } }, - error: err => { + error: (err: any) => { if (options.onError) { options.onError(err); return; From e691fe7c9a2f38f1792dc97c5ed15bfe7b4e29cf Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 11:04:37 -0400 Subject: [PATCH 68/95] Add `react-apollo` `awaitRefetchQueries` docs --- docs/source/api/react-apollo.md | 4 ++++ docs/source/essentials/mutations.md | 2 ++ 2 files changed, 6 insertions(+) diff --git a/docs/source/api/react-apollo.md b/docs/source/api/react-apollo.md index 3ca2cf3f0dc..11e897301cc 100644 --- a/docs/source/api/react-apollo.md +++ b/docs/source/api/react-apollo.md @@ -1190,7 +1190,11 @@ export default graphql(gql`mutation { ... }`, { })(MyComponent); ``` +Please note that refetched queries are handled asynchronously, and by default are not necessarily completed before the mutation has completed. If you want to make sure refetched queries are completed before the mutation is considered done (or resolved), set [`options.awaitRefetchQueries`](#graphql-mutation-options-awaitRefetchQueries) to `true`. +

`options.awaitRefetchQueries`

+ +Queries refetched using [`options.refetchQueries`](#graphql-mutation-options-refetchQueries) are handled asynchronously, which means by default they are not necessarily completed before the mutation has completed. Setting `options.awaitRefetchQueries` to `true` will make sure refetched queries are completed before the mutation is considered done (or resolved). `options.awaitRefetchQueries` is `false` by default.

`options.updateQueries`

diff --git a/docs/source/essentials/mutations.md b/docs/source/essentials/mutations.md index 441ce9212bc..44c0262dead 100644 --- a/docs/source/essentials/mutations.md +++ b/docs/source/essentials/mutations.md @@ -236,6 +236,8 @@ The Mutation component accepts the following props. Only `mutation` and `childre
Provide a [mutation response](../features/optimistic-ui.html) before the result comes back from the server
`refetchQueries`: (mutationResult: FetchResult) => Array<{ query: DocumentNode, variables?: TVariables}>
A function that allows you to specify which queries you want to refetch after a mutation has occurred
+
`awaitRefetchQueries`: boolean
+
Queries refetched as part of `refetchQueries` are handled asynchronously, and are not waited on before the mutation is completed (resolved). Setting this to `true` will make sure refetched queries are completed before the mutation is considered done. `false` by default.
`onCompleted`: (data: TData) => void
A callback executed once your mutation successfully completes
`onError`: (error: ApolloError) => void
From ace499f9920dae493c2807466d73a166bb9867de Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 11:09:39 -0400 Subject: [PATCH 69/95] Changelog updates --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbbec3dadd5..ff0d9101d29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ dependency "graphql@^0.11.0 || ^14.0.0"` errors that people might have seen using `graphql` 0.12.x or 0.13.x.
[@hwillson](https://github.com/hwillson) in [#3746](https://github.com/apollographql/apollo-client/pull/3746) +- Documentation updates.
+ [@hwillson](https://github.com/hwillson) in [#3750](https://github.com/apollographql/apollo-client/pull/3750) ## 2.3.7 (July 24, 2018) From 570e9045e92b04dadc86265338e35b64bd8218d0 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 11:49:26 -0400 Subject: [PATCH 70/95] Update `CONTRIBUTING` doc with feature request repo details --- CONTRIBUTING.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d95eea781d7..e302d5f367c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ Creating a good reproduction really helps contributors investigate and resolve y ### Improving the documentation -Improving the documentation, examples, and other open source content can be the easiest way to contribute to the library. If you see a piece of content that can be better, open a PR with an improvement, no matter how small! If you would like to suggest a big change or major rewrite, we’d love to hear your ideas but please open an issue for discussion before writing the PR. +Improving the documentation, examples, and other open source content can be the easiest way to contribute to the library. If you see a piece of content that can be better, open a PR with an improvement, no matter how small! If you would like to suggest a big change or major rewrite, we’d love to hear your ideas! Please open a feature request for discussion, over in the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests), before writing the PR. ### Responding to issues @@ -43,15 +43,9 @@ For a small bug fix change (less than 20 lines of code changed), feel free to op ### Suggesting features -Most of the features in Apollo came from suggestions by you, the community! We welcome any ideas about how to make Apollo better for your use case. Unless there is overwhelming demand for a feature, it might not get implemented immediately, but please include as much information as possible that will help people have a discussion about your proposal: +Most of the features in Apollo Client came from suggestions by you, the community! We welcome any ideas about how to make Apollo better for your use case. Head on over to the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests), and open up a new feature request issue with your details. -1. **Use case:** What are you trying to accomplish, in specific terms? Often, there might already be a good way to do what you need and a new feature is unnecessary, but it’s hard to know without information about the specific use case. -2. **Could this be a plugin?** In many cases, a feature might be too niche to be included in the core of a library, and is better implemented as a companion package. If there isn’t a way to extend the library to do what you want, could we add additional plugin APIs? It’s important to make the case for why a feature should be part of the core functionality of the library. -3. **Is there a workaround?** Is this a more convenient way to do something that is already possible, or is there some blocker that makes a workaround unfeasible? - -Feature requests will be labeled as such, and we encourage using GitHub issues as a place to discuss new features and possible implementation designs. Please refrain from submitting a pull request to implement a proposed feature until there is consensus that it should be included. This way, you can avoid putting in work that can’t be merged in. - -Once there is a consensus on the need for a new feature, proceed as listed below under “Big PRs”. +**Note:** Feature Requests are no longer managed in this repo's issue tracker. Feature request based issues opened here will be closed. ## Big PRs @@ -62,7 +56,7 @@ This includes: For significant changes to a repository, it’s important to settle on a design before starting on the implementation. This way, we can make sure that major improvements get the care and attention they deserve. Since big changes can be risky and might not always get merged, it’s good to reduce the amount of possible wasted effort by agreeing on an implementation design/plan first. -1. **Open an issue.** Open an issue about your bug or feature, as described above. +1. **Open an issue.** Open an issue about your bug in this repo, or about your feature request in the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests). 2. **Reach consensus.** Some contributors and community members should reach an agreement that this feature or bug is important, and that someone should work on implementing or fixing it. 3. **Agree on intended behavior.** On the issue, reach an agreement about the desired behavior. In the case of a bug fix, it should be clear what it means for the bug to be fixed, and in the case of a feature, it should be clear what it will be like for developers to use the new feature. 4. **Agree on implementation plan.** Write a plan for how this feature or bug fix should be implemented. What modules need to be added or rewritten? Should this be one pull request or multiple incremental improvements? Who is going to do each part? From 860ceba1d5a48dd729b6e1ec08a0b4e30252d864 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 12:05:09 -0400 Subject: [PATCH 71/95] Adjusted feature request triage section --- ISSUE_TRIAGE.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/ISSUE_TRIAGE.md b/ISSUE_TRIAGE.md index 640f40aff6a..6070e469183 100644 --- a/ISSUE_TRIAGE.md +++ b/ISSUE_TRIAGE.md @@ -1,6 +1,6 @@ # Issue Triage -This document describes the process Apollo contributors use to organize issues. We use Github [issues](https://github.com/apollographql/apollo-client/issues) to track bugs and feature requests. Our goal is to maintain a list of issues that are relevant and well-defined (and [labeled](https://github.com/apollographql/apollo-client/labels)) such that a contributor can immediately begin working on the code for a fix or feature request. Contributors who want to dive in and write code aren't likely to prioritize working on issues that are ambiguous and have low impact. +This document describes the process Apollo contributors use to organize issues. We use Github [issues](https://github.com/apollographql/apollo-client/issues) here to track bugs, and issues in the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests) to track feature requests. Our goal is to maintain a list of issues that are relevant and well-defined (and [labeled](https://github.com/apollographql/apollo-client/labels)) such that a contributor can immediately begin working on the code for a fix or feature request. Contributors who want to dive in and write code aren't likely to prioritize working on issues that are ambiguous and have low impact. We would love to have more contributors who are willing to help out with triaging issues. You can begin by helping issue requesters create good reproductions and by confirming those reproductions on your own machine. It won't be long before the core maintainers notice your work and ask whether you'd like to be promoted to an issue maintainer. @@ -31,19 +31,11 @@ The first step is in determining whether the issue is a bug, help question or fe ### Help questions -[Stack Overflow](http://stackoverflow.com/questions/tagged/apollo) and our [Slack channel](http://dev.apollodata.com/#slack) are the place to ask for help on using the framework. Close issues that are help requests and politely refer the author to the above locations. +[Stack Overflow](http://stackoverflow.com/questions/tagged/apollo) and our [Slack channel](https://www.apollographql.com/slack) are the place to ask for help on using the framework. Close issues that are help requests and politely refer the author to the above locations. ### Feature requests -1. For reasons described [here](CONTRIBUTING.md#feature-requests), we would prefer features to be built as separate packages. If the feature can clearly be built as a package, explain this to the requester and close the issue. -> - If the feature could be built as a package and serves a particular need, encourage the user to contribute it themselves. ->- If the underlying issue could be better solved by existing technology, encourage them to seek help in the [Slack channel](http://dev.apollodata.com/#slack) or on [Stack Overflow](http://stackoverflow.com/questions/tagged/apollo). -2. If you haven't closed the issue, add the `feature` label. -3. If it's not possible to build the feature as a package (as you identified in step 1), explore whether creating hooks in core would make it possible to do so. If it would, redefine the issue as a request to create those hooks. -4. Work with the requester and others in the community to build a clear specification for the feature and update the issue description accordingly. -5. Finally, add the `confirmed` label and [classify](#classification) the issue. - -Core contributors may add the `help-wanted` label to feature requests. This indicates the feature is aligned with the project roadmap and a high-quality pull request will almost certainly be merged. +Apollo Client feature requests are managed in the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests). Feature request triaging should happen there. Feature requests opened in this repository should be closed, with a message asking the original requestor to re-open the feature request in the FR repo.

Classification

From 9b77d551d14fabead47fa90c2bf2eaf9281a62be Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 12:05:51 -0400 Subject: [PATCH 72/95] Removed un-necessary PR template content --- .github/PULL_REQUEST_TEMPLATE.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index fea57227de8..4691d24a965 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -22,15 +22,3 @@ - [ ] If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes) - [ ] Make sure all of the significant new logic is covered by tests -- [ ] If this was a change that affects the external API used in GitHunt-React, update GitHunt-React and post a link to the PR in the discussion. - - \ No newline at end of file From 141f3ed333c3a9261286b1952af13bbb7651a751 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 12:14:12 -0400 Subject: [PATCH 73/95] Add note about FR repo and remove labels --- .github/ISSUE_TEMPLATE.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index a5cfa438360..b5c685300a0 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,7 +5,7 @@ If you don't follow the template, your issue may end up being closed without anyone looking at it carefully, because it is not actionable for us without the information in this template. - If you're filing a feature request, you do not need to follow the template, but please mark the feature box at the bottom and include a specific example in which that feature would be useful. + **PLEASE NOTE:** Feature requests and non-bug related discussions no longer managed in this repo. Feature requests should be opened in https://github.com/apollographql/apollo-feature-requests. --> **Intended outcome:** @@ -31,16 +31,3 @@ Run the following command in your project directory, and paste its (automaticall `npx envinfo@latest --preset apollo --clipboard` --> - - From 4984b5cb5f1f73aa938aaa0032dd733261c341c6 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 12:28:06 -0400 Subject: [PATCH 74/95] Slight wording changes to mention "discussions" should be in FR repo --- .github/ISSUE_TEMPLATE.md | 2 +- CONTRIBUTING.md | 4 ++-- ISSUE_TRIAGE.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index b5c685300a0..40e39ef1800 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,7 +5,7 @@ If you don't follow the template, your issue may end up being closed without anyone looking at it carefully, because it is not actionable for us without the information in this template. - **PLEASE NOTE:** Feature requests and non-bug related discussions no longer managed in this repo. Feature requests should be opened in https://github.com/apollographql/apollo-feature-requests. + **PLEASE NOTE:** Feature requests and non-bug related discussions are no longer managed in this repo. Feature requests should be opened in https://github.com/apollographql/apollo-feature-requests. --> **Intended outcome:** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e302d5f367c..b367101f89e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,9 +43,9 @@ For a small bug fix change (less than 20 lines of code changed), feel free to op ### Suggesting features -Most of the features in Apollo Client came from suggestions by you, the community! We welcome any ideas about how to make Apollo better for your use case. Head on over to the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests), and open up a new feature request issue with your details. +Most of the features in Apollo Client came from suggestions by you, the community! We welcome any ideas about how to make Apollo better for your use case. Head on over to the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests), and open up a new feature request / discussion issue with your details. -**Note:** Feature Requests are no longer managed in this repo's issue tracker. Feature request based issues opened here will be closed. +**Note:** Feature requests and non-bug related discussions are no longer managed in this repo's issue tracker. Feature request and/or discussions opened here will be closed. ## Big PRs diff --git a/ISSUE_TRIAGE.md b/ISSUE_TRIAGE.md index 6070e469183..dc05ec80687 100644 --- a/ISSUE_TRIAGE.md +++ b/ISSUE_TRIAGE.md @@ -1,6 +1,6 @@ # Issue Triage -This document describes the process Apollo contributors use to organize issues. We use Github [issues](https://github.com/apollographql/apollo-client/issues) here to track bugs, and issues in the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests) to track feature requests. Our goal is to maintain a list of issues that are relevant and well-defined (and [labeled](https://github.com/apollographql/apollo-client/labels)) such that a contributor can immediately begin working on the code for a fix or feature request. Contributors who want to dive in and write code aren't likely to prioritize working on issues that are ambiguous and have low impact. +This document describes the process Apollo contributors use to organize issues. We use Github [issues](https://github.com/apollographql/apollo-client/issues) here to track bugs, and issues in the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests) to track feature requests and discussions. Our goal is to maintain a list of issues that are relevant and well-defined (and [labeled](https://github.com/apollographql/apollo-client/labels)) such that a contributor can immediately begin working on the code for a fix or feature request. Contributors who want to dive in and write code aren't likely to prioritize working on issues that are ambiguous and have low impact. We would love to have more contributors who are willing to help out with triaging issues. You can begin by helping issue requesters create good reproductions and by confirming those reproductions on your own machine. It won't be long before the core maintainers notice your work and ask whether you'd like to be promoted to an issue maintainer. @@ -35,7 +35,7 @@ The first step is in determining whether the issue is a bug, help question or fe ### Feature requests -Apollo Client feature requests are managed in the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests). Feature request triaging should happen there. Feature requests opened in this repository should be closed, with a message asking the original requestor to re-open the feature request in the FR repo. +Apollo Client feature requests and discussions are managed in the [Apollo Client Feature Request repo](https://github.com/apollographql/apollo-feature-requests). Feature request triaging should happen there. Feature requests and/or discussions opened in this repository should be closed, with a message asking the original requestor to re-open the feature request / discussion in the FR repo.

Classification

From 8cb01d5bcf6be36e98b5470af416c60303c74ee7 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 12:42:00 -0400 Subject: [PATCH 75/95] Jest config adjustmenet to address recent JSDom issue A recent Renovate merged Jest update caused all tests to start to fail, due to JSDom security errors. This config adjustment was recommended in the Jest repo to address this issue. Relates to: https://github.com/facebook/jest/issues/6766#issuecomment-408344243 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ef71a6fade..7d84afba528 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "jest": { "transform": { ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js" - } + }, + "testURL": "http://localhost" }, "lint-staged": { "*.ts*": [ From b651c5c1d75d92afce5cd1215bae9606135acd6d Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 12:52:59 -0400 Subject: [PATCH 76/95] Add Jest JSDom workaround to all package based Jest configs --- packages/apollo-boost/package.json | 3 ++- packages/apollo-cache-inmemory/package.json | 3 ++- packages/apollo-cache/package.json | 3 ++- packages/apollo-client/package.json | 3 ++- packages/apollo-utilities/package.json | 3 ++- packages/graphql-anywhere/package.json | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/apollo-boost/package.json b/packages/apollo-boost/package.json index dfd1fdb8807..c6bc5c2feec 100644 --- a/packages/apollo-boost/package.json +++ b/packages/apollo-boost/package.json @@ -68,6 +68,7 @@ "tsx", "js", "json" - ] + ], + "testURL": "http://localhost" } } diff --git a/packages/apollo-cache-inmemory/package.json b/packages/apollo-cache-inmemory/package.json index 02f258defbe..516df6ad752 100644 --- a/packages/apollo-cache-inmemory/package.json +++ b/packages/apollo-cache-inmemory/package.json @@ -73,6 +73,7 @@ "tsx", "js", "json" - ] + ], + "testURL": "http://localhost" } } diff --git a/packages/apollo-cache/package.json b/packages/apollo-cache/package.json index ee0593af10e..0e27f5d97d7 100644 --- a/packages/apollo-cache/package.json +++ b/packages/apollo-cache/package.json @@ -66,6 +66,7 @@ "tsx", "js", "json" - ] + ], + "testURL": "http://localhost" } } diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index a0db8394e3c..d3801829a3e 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -102,6 +102,7 @@ ], "setupFiles": [ "/scripts/tests.js" - ] + ], + "testURL": "http://localhost" } } diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index 2b23511111a..2d69fe7a082 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -69,6 +69,7 @@ "tsx", "js", "json" - ] + ], + "testURL": "http://localhost" } } diff --git a/packages/graphql-anywhere/package.json b/packages/graphql-anywhere/package.json index 66f040b7cb1..e73a3e123d4 100644 --- a/packages/graphql-anywhere/package.json +++ b/packages/graphql-anywhere/package.json @@ -71,6 +71,7 @@ "tsx", "js", "json" - ] + ], + "testURL": "http://localhost" } } From e480dc7eb0b27624c7e264b295d3beb970a70a57 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 15:15:40 -0400 Subject: [PATCH 77/95] Remove `tooling` label used by renovate `tooling` is too generic as a label, and could be used for any kind of tooling. It doesn't add much when triaging issues, so let's get rid of it. --- renovate.json | 1 - 1 file changed, 1 deletion(-) diff --git a/renovate.json b/renovate.json index de060e90126..4e352a7db73 100644 --- a/renovate.json +++ b/renovate.json @@ -9,7 +9,6 @@ "prCreation": "not-pending", "automerge": "minor", "labels": [ - "tooling", "dependencies" ], "assignees": [ From 928500334048080a5aaedd04106119f2d1ebbca1 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 27 Jul 2018 19:22:38 +0000 Subject: [PATCH 78/95] chore(deps): update dependency start-server-and-test to v1.7.0 --- docs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/package.json b/docs/package.json index 5d44f25eea3..35c9332d598 100644 --- a/docs/package.json +++ b/docs/package.json @@ -18,7 +18,7 @@ "hexo-typescript-api-box": "0.9.2", "meteor-theme-hexo": "1.0.16", "poke-site": "1.3.1", - "start-server-and-test": "1.5.0", + "start-server-and-test": "1.7.0", "typedoc": "0.9.0", "typescript": "2.9.2" }, From 0abde20980987b03d9b31f9387dcd4f64a57dbaa Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 20:56:11 -0400 Subject: [PATCH 79/95] Fixed broken `DataProxy` link Updated `README` link to point to the `DataProxy.ts` file in `apollo-cache`. I've also updated left over `dev.apollodata.com` links I noticed while tracing this issue in the docs. Fixes #3726. --- docs/source/api/react-apollo.md | 2 +- docs/source/basics/queries.md | 4 ++-- packages/apollo-cache-inmemory/README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/api/react-apollo.md b/docs/source/api/react-apollo.md index 11e897301cc..331c4f5a937 100644 --- a/docs/source/api/react-apollo.md +++ b/docs/source/api/react-apollo.md @@ -696,7 +696,7 @@ data.fetchMore({

`data.subscribeToMore(options)`

-This function will set up a subscription, triggering updates whenever the server sends a subscription publication. This requires subscriptions to be set up on the server to properly work. Check out the [subscriptions guide](http://dev.apollodata.com/react/receiving-updates.html#Subscriptions) and the [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws) and [graphql-subscriptions](https://github.com/apollographql/graphql-subscriptions) for more information on getting this set up. +This function will set up a subscription, triggering updates whenever the server sends a subscription publication. This requires subscriptions to be set up on the server to properly work. Check out the [subscriptions guide](../advanced/caching.html#Subscriptions) and the [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws) and [graphql-subscriptions](https://github.com/apollographql/graphql-subscriptions) for more information on getting this set up. This function returns an `unsubscribe` function handler which can be used to unsubscribe later. diff --git a/docs/source/basics/queries.md b/docs/source/basics/queries.md index 8f4f7d5c6af..d687ddaf289 100644 --- a/docs/source/basics/queries.md +++ b/docs/source/basics/queries.md @@ -425,7 +425,7 @@ data.fetchMore({

`data.subscribeToMore(options)`

-This function will set up a subscription, triggering updates whenever the server sends a subscription publication. This requires subscriptions to be set up on the server to properly work. Check out the [subscriptions guide](http://dev.apollodata.com/react/receiving-updates.html#Subscriptions) and the [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws) and [graphql-subscriptions](https://github.com/apollographql/graphql-subscriptions) for more information on getting this set up. +This function will set up a subscription, triggering updates whenever the server sends a subscription publication. This requires subscriptions to be set up on the server to properly work. Check out the [subscriptions guide](../advanced/caching.html#Subscriptions) and the [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws) and [graphql-subscriptions](https://github.com/apollographql/graphql-subscriptions) for more information on getting this set up. This function returns an `unsubscribe` function handler which can be used to unsubscribe later. @@ -433,7 +433,7 @@ A common practice is to wrap the `subscribeToMore` call within `componentWillRec - `[document]`: Document is a required property that accepts a GraphQL subscription created with `graphql-tag`’s `gql` template string tag. It should contain a single GraphQL subscription operation with the data that will be returned. - `[variables]`: The optional variables you may provide that will be used with the `document` option. -- `[updateQuery]`: An optional function that runs every time the server sends an update. This modifies the results of the HOC query. The first argument, `previousResult`, will be the previous data returned by the query you defined in your `graphql()` function. The second argument is an object with two properties. `subscriptionData` is result of the subscription. `variables` is the variables object used with the subscription query. Using these arguments you should return a new data object with the same shape as the GraphQL query you defined in your `graphql()` function. This is similar to the [`fetchMore`](#graphql-query-data-fetchMore) callback. Alternatively, you could update the query using a [reducer](http://dev.apollodata.com/react/cache-updates.html#resultReducers) as part of the [options](http://dev.apollodata.com/react/queries.html#graphql-options) of your `graphql()` function. +- `[updateQuery]`: An optional function that runs every time the server sends an update. This modifies the results of the HOC query. The first argument, `previousResult`, will be the previous data returned by the query you defined in your `graphql()` function. The second argument is an object with two properties. `subscriptionData` is result of the subscription. `variables` is the variables object used with the subscription query. Using these arguments you should return a new data object with the same shape as the GraphQL query you defined in your `graphql()` function. This is similar to the [`fetchMore`](#graphql-query-data-fetchMore) callback. Alternatively, you could update the query using a [reducer](../advanced/caching.html#resultReducers) as part of the [options](../essentials/queries.html#graphql-options) of your `graphql()` function. - `[onError]`: An optional error callback. In order to update the query's store with the result of the subscription, you must specify either the `updateQuery` option in `subscribeToMore` or the `reducer` option in your `graphql()` function. diff --git a/packages/apollo-cache-inmemory/README.md b/packages/apollo-cache-inmemory/README.md index 4d8944521fc..f0ed8517cc6 100644 --- a/packages/apollo-cache-inmemory/README.md +++ b/packages/apollo-cache-inmemory/README.md @@ -68,7 +68,7 @@ const cache = new InMemoryCache({

Direct Cache Access

-To interact directly with your cache, you can use the Apollo Client class methods readQuery, readFragment, writeQuery, and writeFragment. These methods are available to us via the [`DataProxy` interface](http://dev.apollodata.com/core/apollo-client-api.html#DataProxy). Accessing these methods will vary slightly based on your view layer implementation. If you are using React, you can wrap your component in the `withApollo` higher order component, which will give you access to `this.props.client`. From there, you can use the methods to control your data. +To interact directly with your cache, you can use the Apollo Client class methods readQuery, readFragment, writeQuery, and writeFragment. These methods are available to us via the [`DataProxy` interface](https://github.com/apollographql/apollo-client/blob/master/packages/apollo-cache/src/types/DataProxy.ts). Accessing these methods will vary slightly based on your view layer implementation. If you are using React, you can wrap your component in the `withApollo` higher order component, which will give you access to `this.props.client`. From there, you can use the methods to control your data. Any code demonstration in the following sections will assume that we have already initialized an instance of `ApolloClient` and that we have imported the `gql` tag from `graphql-tag`. From e508020dbed1bf6817bf44d946862e3b82bcca30 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 27 Jul 2018 21:00:41 -0400 Subject: [PATCH 80/95] Changelog update --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0d9101d29..d1e8b31e553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ seen using `graphql` 0.12.x or 0.13.x.
[@hwillson](https://github.com/hwillson) in [#3746](https://github.com/apollographql/apollo-client/pull/3746) - Documentation updates.
- [@hwillson](https://github.com/hwillson) in [#3750](https://github.com/apollographql/apollo-client/pull/3750) + [@hwillson](https://github.com/hwillson) in [#3750](https://github.com/apollographql/apollo-client/pull/3750)
+ [@hwillson](https://github.com/hwillson) in [#3754](https://github.com/apollographql/apollo-client/pull/3754) ## 2.3.7 (July 24, 2018) From f28e16aa06d1574a387d967b3491c6a7594e3bda Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 28 Jul 2018 02:39:46 +0000 Subject: [PATCH 81/95] chore(deps): update dependency @types/lodash to v4.14.115 --- packages/apollo-cache-inmemory/package.json | 2 +- packages/apollo-client/package.json | 2 +- packages/apollo-utilities/package.json | 2 +- packages/graphql-anywhere/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/apollo-cache-inmemory/package.json b/packages/apollo-cache-inmemory/package.json index 516df6ad752..13a6eebbf45 100644 --- a/packages/apollo-cache-inmemory/package.json +++ b/packages/apollo-cache-inmemory/package.json @@ -50,7 +50,7 @@ "devDependencies": { "@types/graphql": "0.12.7", "@types/jest": "22.2.3", - "@types/lodash": "4.14.113", + "@types/lodash": "4.14.115", "browserify": "15.2.0", "graphql": "0.13.2", "graphql-tag": "2.9.2", diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index d3801829a3e..b9ce728f71b 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -62,7 +62,7 @@ "@types/graphql": "0.12.7", "@types/isomorphic-fetch": "0.0.34", "@types/jest": "22.2.3", - "@types/lodash": "4.14.113", + "@types/lodash": "4.14.115", "@types/node": "10.5.2", "apollo-cache-inmemory": "^1.2.6", "benchmark": "2.1.4", diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index 2d69fe7a082..93bde167604 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -44,7 +44,7 @@ "devDependencies": { "@types/graphql": "0.12.7", "@types/jest": "22.2.3", - "@types/lodash": "4.14.113", + "@types/lodash": "4.14.115", "@types/node": "10.5.2", "browserify": "15.2.0", "flow-bin": "0.77.0", diff --git a/packages/graphql-anywhere/package.json b/packages/graphql-anywhere/package.json index e73a3e123d4..a6f17aebbb3 100644 --- a/packages/graphql-anywhere/package.json +++ b/packages/graphql-anywhere/package.json @@ -45,7 +45,7 @@ "@types/graphql": "0.12.7", "@types/isomorphic-fetch": "0.0.34", "@types/jest": "22.2.3", - "@types/lodash": "4.14.113", + "@types/lodash": "4.14.115", "@types/node": "10.5.2", "@types/react": "16.0.34", "@types/react-dom": "16.0.4", From a0173cd390ccedf18b13c2d2a8ed27f7d9ebad13 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 29 Jul 2018 04:46:08 +0000 Subject: [PATCH 82/95] chore(deps): update dependency uglify-js to v3.4.6 --- packages/apollo-client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index b9ce728f71b..29b457feee6 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -82,7 +82,7 @@ "ts-jest": "20.0.14", "tslint": "5.11.0", "typescript": "2.9.2", - "uglify-js": "3.4.5", + "uglify-js": "3.4.6", "webpack": "3.12.0", "webpack-bundle-analyzer": "2.13.1" }, From 70ce7c79440bbdc1a07d904193b097d348ec786e Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 30 Jul 2018 08:12:23 +0000 Subject: [PATCH 83/95] chore(deps): update dependency @types/node to v10.5.4 --- packages/apollo-client/package.json | 2 +- packages/apollo-utilities/package.json | 2 +- packages/graphql-anywhere/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index 29b457feee6..95e50bc4dc4 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -63,7 +63,7 @@ "@types/isomorphic-fetch": "0.0.34", "@types/jest": "22.2.3", "@types/lodash": "4.14.115", - "@types/node": "10.5.2", + "@types/node": "10.5.4", "apollo-cache-inmemory": "^1.2.6", "benchmark": "2.1.4", "browserify": "15.2.0", diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index 93bde167604..3d772399733 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -45,7 +45,7 @@ "@types/graphql": "0.12.7", "@types/jest": "22.2.3", "@types/lodash": "4.14.115", - "@types/node": "10.5.2", + "@types/node": "10.5.4", "browserify": "15.2.0", "flow-bin": "0.77.0", "graphql": "0.13.2", diff --git a/packages/graphql-anywhere/package.json b/packages/graphql-anywhere/package.json index a6f17aebbb3..5c6872d4ff0 100644 --- a/packages/graphql-anywhere/package.json +++ b/packages/graphql-anywhere/package.json @@ -46,7 +46,7 @@ "@types/isomorphic-fetch": "0.0.34", "@types/jest": "22.2.3", "@types/lodash": "4.14.115", - "@types/node": "10.5.2", + "@types/node": "10.5.4", "@types/react": "16.0.34", "@types/react-dom": "16.0.4", "browserify": "15.2.0", From 671c83c99ee219c1c5795e084abf2997ec0704a9 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Mon, 30 Jul 2018 08:33:11 -0400 Subject: [PATCH 84/95] New issue templates --- .github/ISSUE_REPLY_TEMPLATE.md | 16 ---------------- .../{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug.md} | 5 +++++ .github/ISSUE_TEMPLATE/discussion-question.md | 11 +++++++++++ .github/ISSUE_TEMPLATE/feature-request.md | 10 ++++++++++ 4 files changed, 26 insertions(+), 16 deletions(-) delete mode 100644 .github/ISSUE_REPLY_TEMPLATE.md rename .github/{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug.md} (94%) create mode 100644 .github/ISSUE_TEMPLATE/discussion-question.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md diff --git a/.github/ISSUE_REPLY_TEMPLATE.md b/.github/ISSUE_REPLY_TEMPLATE.md deleted file mode 100644 index e556e1a1842..00000000000 --- a/.github/ISSUE_REPLY_TEMPLATE.md +++ /dev/null @@ -1,16 +0,0 @@ -### Thanks for filing an issue on Apollo Client! - -To make things easier for you and for a maintiner or contributor to help out, here are a few useful resources! - -### Contributing to Apollo -If this is your first time contributing to Apollo, one of our friendly bots will ask for you to sign the CLA. After that, take a look at the [contributor guide](https://github.com/apollographql/apollo-client/blob/master/CONTRIBUTING.md)! - -### Creating a reproduction: -- You can create a reproduction using [this template](https://codesandbox.io/s/7361K9q6w) on codesandbox, or try it locally using [the apollo error template](https://github.com/apollographql/react-apollo-error-template). -- If you want to customize the schema to match the issue you are having, checkout [Apollo Launchpad](https://launchpad.graphql.com/new). -- If your issue is related to react-native, try using [Expo](https://snack.expo.io/). - -### Guides and Documentation -The issue you are having (or the feature you are requesting) may already be fixed! To find the latest information about how to use Apollo, check out the [documentation](http://www.apollographql.com/docs/) and see the latest posts from [the Apollo GraphQL blog](https://blog.apollographql.com/). - -Thank you again for helping to improve Apollo Client! diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug.md similarity index 94% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug.md index 40e39ef1800..76e6b1f291f 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,3 +1,8 @@ +--- +name: 🐛 Reporting a Bug +about: Open a new issue here if something isn't working as expected. +--- +