apollo-datasource-mongodb icon indicating copy to clipboard operation
apollo-datasource-mongodb copied to clipboard

`deleteFromCacheByFields` fails when the query only uses one field

Open eth0lo opened this issue 4 years ago • 4 comments

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

eth0lo avatar Sep 27 '21 16:09 eth0lo

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.

tubbo avatar Sep 27 '21 16:09 tubbo

Any progress on this?

bentburton avatar May 08 '22 05:05 bentburton

Having the same issue

bentburton avatar May 08 '22 05:05 bentburton

Addressed in 95

bentburton avatar May 10 '22 21:05 bentburton