@envelop/response-cache 9.2.0 → 9.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ const createInMemoryCache = (params) => {
8
8
  max: params?.max ?? 1000,
9
9
  allowStale: false,
10
10
  noDisposeOnSet: true,
11
- dispose(responseId) {
11
+ dispose(_value, responseId) {
12
12
  purgeResponse(responseId, false);
13
13
  },
14
14
  });
@@ -19,8 +19,13 @@ const createInMemoryCache = (params) => {
19
19
  // get entities related to the response
20
20
  if (entityIds !== undefined) {
21
21
  for (const entityId of entityIds) {
22
- // remove the response mapping from the entity
23
- entityToResponseIds.get(entityId)?.delete(responseId);
22
+ const responseIds = entityToResponseIds.get(entityId);
23
+ if (responseIds) {
24
+ responseIds.delete(responseId);
25
+ if (responseIds.size === 0) {
26
+ entityToResponseIds.delete(entityId);
27
+ }
28
+ }
24
29
  }
25
30
  // remove all the entity mappings from the response
26
31
  responseIdToEntityIds.delete(responseId);
@@ -5,7 +5,7 @@ export const createInMemoryCache = (params) => {
5
5
  max: params?.max ?? 1000,
6
6
  allowStale: false,
7
7
  noDisposeOnSet: true,
8
- dispose(responseId) {
8
+ dispose(_value, responseId) {
9
9
  purgeResponse(responseId, false);
10
10
  },
11
11
  });
@@ -16,8 +16,13 @@ export const createInMemoryCache = (params) => {
16
16
  // get entities related to the response
17
17
  if (entityIds !== undefined) {
18
18
  for (const entityId of entityIds) {
19
- // remove the response mapping from the entity
20
- entityToResponseIds.get(entityId)?.delete(responseId);
19
+ const responseIds = entityToResponseIds.get(entityId);
20
+ if (responseIds) {
21
+ responseIds.delete(responseId);
22
+ if (responseIds.size === 0) {
23
+ entityToResponseIds.delete(entityId);
24
+ }
25
+ }
21
26
  }
22
27
  // remove all the entity mappings from the response
23
28
  responseIdToEntityIds.delete(responseId);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@envelop/response-cache",
3
- "version": "9.2.0",
3
+ "version": "9.3.1",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
7
- "@envelop/core": "^5.6.0"
7
+ "@envelop/core": "^5.6.1"
8
8
  },
9
9
  "dependencies": {
10
10
  "@graphql-tools/utils": "^11.2.0",
@@ -19,6 +19,7 @@
19
19
  "url": "https://github.com/graphql-hive/graphql-yoga.git",
20
20
  "directory": "packages/envelop/plugins/response-cache"
21
21
  },
22
+ "homepage": "https://github.com/graphql-hive/graphql-yoga/tree/main/packages/envelop/plugins/response-cache#readme",
22
23
  "author": "Kamil Kisiela <kamilkisiela@gmail.com>",
23
24
  "license": "MIT",
24
25
  "engines": {