Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn when user try to use apollo-boost as an apollo-client #3551

Merged
merged 9 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.json
*.snap
217 changes: 110 additions & 107 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br/>
[@ananth99](https://github.com/ananth99) in [#3599](https://github.com/apollographql/apollo-client/pull/3599) <br/>
[@hwillson](https://github.com/hwillson) in [#3635](https://github.com/apollographql/apollo-client/pull/3635) <br/>
[@JakeDawkins](https://github.com/JakeDawkins) in [#3642](https://github.com/apollographql/apollo-client/pull/3642) <br/>
[@hwillson](https://github.com/hwillson) in [#3644](https://github.com/apollographql/apollo-client/pull/3644) <br/>
[@gbau](https://github.com/gbau) in [#3644](https://github.com/apollographql/apollo-client/pull/3600) <br/>
[@chentsulin](https://github.com/chentsulin) in [#3608](https://github.com/apollographql/apollo-client/pull/3608) <br/>
[@MikaelCarpenter](https://github.com/MikaelCarpenter) in [#3609](https://github.com/apollographql/apollo-client/pull/3609) <br/>
[@Gamezpedia](https://github.com/Gamezpedia) in [#3612](https://github.com/apollographql/apollo-client/pull/3612) <br/>
[@jinxac](https://github.com/jinxac) in [#3647](https://github.com/apollographql/apollo-client/pull/3647) <br/>
[@abernix](https://github.com/abernix) in [#3705](https://github.com/apollographql/apollo-client/pull/3705) <br/>
[@dandv](https://github.com/dandv) in [#3703](https://github.com/apollographql/apollo-client/pull/3703) <br/>
[@hwillson](https://github.com/hwillson) in [#3580](https://github.com/apollographql/apollo-client/pull/3580) <br/>
- Updated `graphql` `peerDependencies` to handle 14.x versions. <br/>
[@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. <br/>
[@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`. <br/>
[@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. <br/>
[@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. <br/>
[@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. <br/>
[@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) <br/>
[@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. <br/>
[@hwillson](https://github.com/hwillson) in [#3711](https://github.com/apollographql/apollo-client/pull/3711)

## 2.3.5 (June 19, 2018)
Expand Down Expand Up @@ -120,8 +123,8 @@
variables: `ObservableQuery<TData, TVariables>`
([@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
Expand All @@ -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))
2 changes: 2 additions & 0 deletions packages/apollo-boost/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- 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)
- The `apollo-boost` `ApolloClient` constructor warns about unsupported options.
[PR #3551](https://github.com/apollographql/apollo-client/pull/3551)

### 0.1.10

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`config warns about unsupported parameter 1`] = `
Array [
Array [
"ApolloBoost was initialized with unsupported options: link",
],
]
`;
10 changes: 10 additions & 0 deletions packages/apollo-boost/src/__tests__/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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 custom fetcher', () => {
const customFetcher = jest.fn(() =>
Promise.resolve({
Expand Down
36 changes: 36 additions & 0 deletions packages/apollo-boost/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,44 @@ export interface PresetConfig {
cache?: ApolloCache<any>;
}

// 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',
'credentials',
'headers',
'fetch',
'fetchOptions',
'clientState',
'onError',
'cacheRedirects',
'cache',
];

export default class DefaultClient<TCache> extends ApolloClient<TCache> {
constructor(config: PresetConfig = {}) {
if (config) {
const diff = Object.keys(config).filter(
key => PRESET_CONFIG_KEYS.indexOf(key) === -1,
);

if (diff.length > 0) {
console.warn(
'ApolloBoost was initialized with unsupported options: ' +
`${diff.join(' ')}`,
);
}
}

const {
request,
uri,
Expand Down