GraphQLGuide / apollo-datasource-mongodb

Apollo data source for MongoDB
MIT License
285 stars 64 forks source link

`deleteFromCacheByFields` fails when the query only uses one field #81

Open eth0lo opened 3 years ago

eth0lo commented 3 years ago

For example.

this.findByFields({
  tag: new ObjectId('some-tag-id')
})

and

this.deleteFromCacheByFields({
  tag: new ObjectId('some-tag-id')
})

generate different keys, for this case it will generate: {"tag":{"$oid":"6151e9b4b005977991064607"}} and {"tag":[{"$oid":"6151e9b4b005977991064607"}]} respectively; which will prevent the method from behaving correctly

the issue is generated here

tubbo commented 3 years ago

The logic on https://github.com/GraphQLGuide/apollo-datasource-mongodb/blob/master/src/cache.js#L187-L200 basically needs to make its way into deleteFromCacheByFields() as that will make the keys match up.

bentburton commented 2 years ago

Any progress on this?

bentburton commented 2 years ago

Having the same issue

bentburton commented 2 years ago

Addressed in 95