ember-graphql / ember-apollo-client

🚀 An ember-cli addon for Apollo Client and GraphQL
MIT License
280 stars 72 forks source link

Use WeakMap for storing observables and unsubscribeFn #343

Closed josemarluedke closed 4 years ago

josemarluedke commented 4 years ago

Previously, we would store the observables and the unsubscribeFn as a property in the returned data from the GraphQL. This meant users could not use freezeResults: true option from InMemoryCache as we would mutate the result.

Now we have migrated to store both, the observable and the unsubscribeFn in a weak map.

The functions getObservable and unsubscribe should just work as before.

Fixes #332.

cc/ @charlesdemers.