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

fix: use empty object as default inMemoryCacheOptions #153

Merged
merged 1 commit into from
Jun 28, 2019

Conversation

haoqunjiang
Copy link
Contributor

Using null as default is dangerous here:

  1. It passes type checking if strictNullChecks not enabled
  2. It won't trigger default parameter assignment (only undefined will)

In the case of apollo-cache-inmemory v1.6.0, a bug is triggered due to
the default null value, see:
https://github.com/apollographql/apollo-client/blob/d9e93e31fa40da6d9ee55e99e8e1cb114dba6639/packages/apollo-cache-inmemory/src/inMemoryCache.ts#L136

Though it can also be fixed on their side, it's better to use a safer
default value.

Using `null` as default is dangerous here:

1. It passes type checking if `strictNullChecks` not enabled
2. It won't trigger default parameter assignment (only `undefined` will)

In the case of apollo-cache-inmemory v1.6.0, a bug is triggered due to
the default `null` value, see:
https://github.com/apollographql/apollo-client/blob/d9e93e31fa40da6d9ee55e99e8e1cb114dba6639/packages/apollo-cache-inmemory/src/inMemoryCache.ts#L136

Though it can also be fixed on their side, it's better to use a safer
default value.
@Akryum Akryum merged commit 15871ff into Akryum:master Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants