@envelop/response-cache 3.1.1-alpha-20220824165935-4720f031 → 3.2.0

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.
Files changed (2) hide show
  1. package/README.md +0 -87
  2. package/package.json +4 -3
package/README.md CHANGED
@@ -38,15 +38,10 @@ When configuring the `useResponseCache`, you can choose the type of cache:
38
38
  The in-memory LRU cache is used by default.
39
39
 
40
40
  ```ts
41
- import { parse, validate, execute, subscribe } from 'graphql'
42
41
  import { envelop } from '@envelop/core'
43
42
  import { useResponseCache } from '@envelop/response-cache'
44
43
 
45
44
  const getEnveloped = envelop({
46
- parse,
47
- validate,
48
- execute,
49
- subscribe,
50
45
  plugins: [
51
46
  // ... other plugins ...
52
47
  useResponseCache({
@@ -60,17 +55,12 @@ const getEnveloped = envelop({
60
55
  Or, you may create the in-memory LRU cache explicitly.
61
56
 
62
57
  ```ts
63
- import { parse, validate, execute, subscribe } from 'graphql'
64
58
  import { envelop } from '@envelop/core'
65
59
  import { useResponseCache, createInMemoryCache } from '@envelop/response-cache'
66
60
 
67
61
  const cache = createInMemoryCache()
68
62
 
69
63
  const getEnveloped = envelop({
70
- parse,
71
- validate,
72
- execute,
73
- subscribe,
74
64
  plugins: [
75
65
  // ... other plugins ...
76
66
  useResponseCache({
@@ -86,15 +76,10 @@ const getEnveloped = envelop({
86
76
  ### Cache based on session/user
87
77
 
88
78
  ```ts
89
- import { parse, validate, execute, subscribe } from 'graphql'
90
79
  import { envelop } from '@envelop/core'
91
80
  import { useResponseCache } from '@envelop/response-cache'
92
81
 
93
82
  const getEnveloped = envelop({
94
- parse,
95
- validate,
96
- execute,
97
- subscribe,
98
83
  plugins: [
99
84
  // ... other plugins ...
100
85
  useResponseCache({
@@ -120,7 +105,6 @@ In order to use the Redis cache, you need to:
120
105
  - Create an instance of the Redis Cache and set to the `useResponseCache` plugin options
121
106
 
122
107
  ```ts
123
- import { parse, validate, execute, subscribe } from 'graphql'
124
108
  import { envelop } from '@envelop/core'
125
109
  import { useResponseCache } from '@envelop/response-cache'
126
110
  import { createRedisCache } from '@envelop/response-cache-redis'
@@ -138,10 +122,6 @@ const redis = new Redis('rediss://:1234567890@my-redis-db.example.com:30652')
138
122
  const cache = createRedisCache({ redis })
139
123
 
140
124
  const getEnveloped = envelop({
141
- parse,
142
- validate,
143
- execute,
144
- subscribe,
145
125
  plugins: [
146
126
  // ... other plugins ...
147
127
  useResponseCache({
@@ -159,15 +139,10 @@ const getEnveloped = envelop({
159
139
  ### Cache with maximum TTL
160
140
 
161
141
  ```ts
162
- import { parse, validate, execute, subscribe } from 'graphql'
163
142
  import { envelop } from '@envelop/core'
164
143
  import { useResponseCache } from '@envelop/response-cache'
165
144
 
166
145
  const getEnveloped = envelop({
167
- parse,
168
- validate,
169
- execute,
170
- subscribe,
171
146
  plugins: [
172
147
  // ... other plugins ...
173
148
  useResponseCache({
@@ -183,15 +158,10 @@ const getEnveloped = envelop({
183
158
  ### Cache with custom TTL per object type
184
159
 
185
160
  ```ts
186
- import { parse, validate, execute, subscribe } from 'graphql'
187
161
  import { envelop } from '@envelop/core'
188
162
  import { useResponseCache } from '@envelop/response-cache'
189
163
 
190
164
  const getEnveloped = envelop({
191
- parse,
192
- validate,
193
- execute,
194
- subscribe,
195
165
  plugins: [
196
166
  // ... other plugins ...
197
167
  useResponseCache({
@@ -208,15 +178,10 @@ const getEnveloped = envelop({
208
178
  ### Cache with custom TTL per schema coordinate
209
179
 
210
180
  ```ts
211
- import { parse, validate, execute, subscribe } from 'graphql'
212
181
  import { envelop } from '@envelop/core'
213
182
  import { useResponseCache } from '@envelop/response-cache'
214
183
 
215
184
  const getEnveloped = envelop({
216
- parse,
217
- validate,
218
- execute,
219
- subscribe,
220
185
  plugins: [
221
186
  // ... other plugins ...
222
187
  useResponseCache({
@@ -233,15 +198,10 @@ const getEnveloped = envelop({
233
198
  ### Disable cache based on session/user
234
199
 
235
200
  ```ts
236
- import { parse, validate, execute, subscribe } from 'graphql'
237
201
  import { envelop } from '@envelop/core'
238
202
  import { useResponseCache } from '@envelop/response-cache'
239
203
 
240
204
  const getEnveloped = envelop({
241
- parse,
242
- validate,
243
- execute,
244
- subscribe,
245
205
  plugins: [
246
206
  // ... other plugins ...
247
207
  useResponseCache({
@@ -268,7 +228,6 @@ cache results with certain error types.
268
228
  By default, the `defaultShouldCacheResult` function is used which never caches any query operation execution results that includes any errors (unexpected, EnvelopError, or GraphQLError).
269
229
 
270
230
  ```ts
271
- import { parse, validate, execute, subscribe } from 'graphql'
272
231
  import { envelop } from '@envelop/core'
273
232
  import { useResponseCache, ShouldCacheResultFunction } from '@envelop/response-cache'
274
233
 
@@ -279,10 +238,6 @@ export const defaultShouldCacheResult: ShouldCacheResultFunction = (params): Boo
279
238
  }
280
239
 
281
240
  const getEnveloped = envelop({
282
- parse,
283
- validate,
284
- execute,
285
- subscribe,
286
241
  plugins: [
287
242
  // ... other plugins ...
288
243
  useResponseCache({
@@ -300,15 +255,10 @@ By default introspection query operations are not cached. In case you want to ca
300
255
  **Infinite caching**
301
256
 
302
257
  ```ts
303
- import { parse, validate, execute, subscribe } from 'graphql'
304
258
  import { envelop } from '@envelop/core'
305
259
  import { useResponseCache } from '@envelop/response-cache'
306
260
 
307
261
  const getEnveloped = envelop({
308
- parse,
309
- validate,
310
- execute,
311
- subscribe,
312
262
  plugins: [
313
263
  // ... other plugins ...
314
264
  useResponseCache({
@@ -324,15 +274,10 @@ const getEnveloped = envelop({
324
274
  **TTL caching**
325
275
 
326
276
  ```ts
327
- import { parse, validate, execute, subscribe } from 'graphql'
328
277
  import { envelop } from '@envelop/core'
329
278
  import { useResponseCache } from '@envelop/response-cache'
330
279
 
331
280
  const getEnveloped = envelop({
332
- parse,
333
- validate,
334
- execute,
335
- subscribe,
336
281
  plugins: [
337
282
  // ... other plugins ...
338
283
  useResponseCache({
@@ -348,15 +293,10 @@ const getEnveloped = envelop({
348
293
  ### Cache with maximum TTL
349
294
 
350
295
  ```ts
351
- import { parse, validate, execute, subscribe } from 'graphql'
352
296
  import { envelop } from '@envelop/core'
353
297
  import { useResponseCache } from '@envelop/response-cache'
354
298
 
355
299
  const getEnveloped = envelop({
356
- parse,
357
- validate,
358
- execute,
359
- subscribe,
360
300
  plugins: [
361
301
  // ... other plugins ...
362
302
  useResponseCache({
@@ -370,15 +310,10 @@ const getEnveloped = envelop({
370
310
  ### Customize the fields that are used for building the cache ID
371
311
 
372
312
  ```ts
373
- import { parse, validate, execute, subscribe } from 'graphql'
374
313
  import { envelop } from '@envelop/core'
375
314
  import { useResponseCache } from '@envelop/response-cache'
376
315
 
377
316
  const getEnveloped = envelop({
378
- parse,
379
- validate,
380
- execute,
381
- subscribe,
382
317
  plugins: [
383
318
  // ... other plugins ...
384
319
  useResponseCache({
@@ -394,15 +329,10 @@ const getEnveloped = envelop({
394
329
  ### Disable automatic cache invalidation via mutations
395
330
 
396
331
  ```ts
397
- import { parse, validate, execute, subscribe } from 'graphql'
398
332
  import { envelop } from '@envelop/core'
399
333
  import { useResponseCache } from '@envelop/response-cache'
400
334
 
401
335
  const getEnveloped = envelop({
402
- parse,
403
- validate,
404
- execute,
405
- subscribe,
406
336
  plugins: [
407
337
  // ... other plugins ...
408
338
  useResponseCache({
@@ -418,7 +348,6 @@ const getEnveloped = envelop({
418
348
  ### Invalidate Cache based on custom logic
419
349
 
420
350
  ```ts
421
- import { parse, validate, execute, subscribe } from 'graphql'
422
351
  import { envelop } from '@envelop/core'
423
352
  import { useResponseCache, createInMemoryCache } from '@envelop/response-cache'
424
353
  import { emitter } from './eventEmitter'
@@ -427,10 +356,6 @@ import { emitter } from './eventEmitter'
427
356
  const cache = createInMemoryCache()
428
357
 
429
358
  const getEnveloped = envelop({
430
- parse,
431
- validate,
432
- execute,
433
- subscribe,
434
359
  plugins: [
435
360
  // ... other plugins ...
436
361
  useResponseCache({
@@ -455,7 +380,6 @@ emitter.on('invalidate', resource => {
455
380
  ### Customize how cache ids are built
456
381
 
457
382
  ```ts
458
- import { parse, validate, execute, subscribe } from 'graphql'
459
383
  import { envelop } from '@envelop/core'
460
384
  import { useResponseCache, createInMemoryCache } from '@envelop/response-cache'
461
385
  import { emitter } from './eventEmitter'
@@ -467,10 +391,6 @@ const cache = createInMemoryCache({
467
391
  })
468
392
 
469
393
  const getEnveloped = envelop({
470
- parse,
471
- validate,
472
- execute,
473
- subscribe,
474
394
  plugins: [
475
395
  // ... other plugins ...
476
396
  useResponseCache({
@@ -488,14 +408,7 @@ const getEnveloped = envelop({
488
408
  For debugging or monitoring it might be useful to know whether a response got served from the cache or not.
489
409
 
490
410
  ```ts
491
- import { parse, validate, execute, subscribe } from 'graphql'
492
- import { envelop } from '@envelop/core'
493
-
494
411
  const getEnveloped = envelop({
495
- parse,
496
- validate,
497
- execute,
498
- subscribe,
499
412
  plugins: [
500
413
  // ... other plugins ...
501
414
  useResponseCache({
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@envelop/response-cache",
3
- "version": "3.1.1-alpha-20220824165935-4720f031",
3
+ "version": "3.2.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.5.1-alpha-20220824165935-4720f031",
6
+ "@envelop/core": "^2.6.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
10
10
  "@graphql-tools/utils": "^8.8.0",
11
11
  "lru-cache": "^6.0.0",
12
- "fast-json-stable-stringify": "^2.1.0"
12
+ "fast-json-stable-stringify": "^2.1.0",
13
+ "tslib": "^2.4.0"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",